Wednesday, November 14, 2007

Linker error and sipXtapi

If you get the following error:

Invoking: GCC C++ Linker
g++ -L../../src/.libs/ -L../../src/libs/ -lQtGui -lQtCore -o"my_sipXezPhone" ./fred.o ./main.o ./moc_myqtapp.o ./myqtapp.o

./myqtapp.o: In function `myQtApp::show()':
/root/sipXtapi/sipXcallLib/workspace/my_sipXezPhone/Debug/../myqtapp.cpp:115: undefined reference to `sipxInitialize'
collect2: ld returned 1 exit status

It because the linker cannot find the object file. Do the following

Add the following path to the linker library search path: directory where sipxtapi is installed/sipXcallib/src/.libs/

Add the following entry to the linker libraries: sipXcall

In Eclipse, it would look like this:

A couple of webpages that helped me get to the solution:

http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/gcc/Link-Options.html

Relevant text:

-l library
Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)

It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.

The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name.

The directories searched include several standard system directories plus any that you specify with -L.

Normally the files found this way are library files—archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an -l option and specifying a file name is that -l surrounds library with lib and .a and searches several directories.

http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html

No comments:

  • Book reviews