I am having a lot of troubles getting a shared object file to link with an existing program. The program had been previously created in PhAB, and has PhAB’s makefile structure.
I have created a library called liblasag.so and placed it in the /lib/dll directory (which is registered in the LD_LIBRARY_PATH variable). The library’s header file is also included in the correct places in the program.
Now I have tried to modify the Makefile in the program’s /src/gcc_ntox86 directory, but without much success. I have added -llasag, -l /lib/dll/liblasag.so and other variants (capital L etc) both infront of and behind the object files in the linking command. I think I have tried all the possible combinations, but I am not sure. If someone could let me in on the magic secret that’d be great.
The error is: undefined reference to ‘function’. It occurs once for each place a library function is called.
I do have files with exactly what you have above: #ifdef __cplusplus
extern “C” { #endif
They occur in files that typically start with dmc… (such as dmcisa, dmcint, dmcsup etc - I don’t know what they all do as this is someone elses program, although im pretty sure they are libraries for a pci card that is used).
However, when I tried to comment out these sections, it gave me even more errors for other functions that are in the dmcisa files. I’m not too sure what the __cplusplus means, is this something I can easily get rid of (and how), or do I have to find other non C++ versions of this library.
The -L/lib/dll -llasag command still generates an “undefined reference”. I have looked at the other files that have the __cplusplus argument and they compile in a version of the code that doesn’t use the library I am trying to add, and when I add the library, nothing in those files with the __cplusplus arguments change. If anyone has any suggestions that would be great - thanks
Well, you shouldn’t be putting the file in /lib/dll if it is a library. You should also be giving the shlib a soname (liblasag.so.1). Could you post the output from the link stage so we can see the exact errors you are getting?
try to re-arrange the order of the libs. I normally put my own libs before the system libs.
I suspect your “dmcqnx.lib” uses lasag lib. try to move -llasag AFTER the -l/opt/galil/dmcqnx.lib
Rearranging the order like you said doesn’t work. The dmcqnx.lib does not use lasag, since dmcqnx.lib were provided by the hardware vendor and liblasag.so is something I developed myself for another piece of hardware entirely.
-Now this program was originally developed in a free version of qnx using PhAB, however I am now adding the liblasag.so library in the latest version, 6.2.1b - are there any compatibility issues there?
I saw your link command uses QCC so I assume you are dealing with C++. I vaguely remember PhAB has issues with C++ (or does it support C++?). Hope cdm or others can give more information.