0

I need some help understanding why this is not working. I have a .h file that declares a function defined within a .so file:

/* navApi.h */
void navApi_init();     /* resides in libNavApi.so */

and a .cpp file:

/* test.cpp */
#include <iostream>
#include "navApi.h"

int main(void)
{
    std::cout << "start...\n";
    navApi_Init();
}

I compiled using:

g++ test.cpp -navApi

I'm getting the following error:

test.cpp: (.txt+0x1e): undefined reference to `navApi_Init()'
collect2: error: ld returned 1 exit status

-- running on linux, ubuntu --

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
OliverGainess
  • 163
  • 1
  • 8

1 Answers1

1

It's a linker error, not finding libnavApi.so

g++ test.cpp -lnavApi

might work if libnavApi.so is in a path that g++ knows about.

ldav1s
  • 15,885
  • 2
  • 53
  • 56