03-09-2016 07:51 AM
Hi,
I have a shared object that i would import with "Import Shared Object" to create a library, but It contains a function defined in another file(#nclude), so i can't use the lvlib that LV produces.
Can i resolve this problem? How i must create shared object that include other .o?
Thanks.
Solved! Go to Solution.
03-09-2016 09:13 AM - edited 03-09-2016 09:14 AM
What shared object? Do you mean a shared library and then on Linux?
If it is this then you just have to make sure that the other .so file that your .so file refers to is also installed on the target machine.
03-09-2016 10:23 AM
The initial file .cpp include other .cpp for use function. How can I include other .o? I must use, for example:
g++ name.o -shared -o libname.so
with the "-L" option?
g++ name.o -shared -o libname.so -L /usr/lib/name2.so
Is it right?
Thanks.
03-09-2016 11:01 AM
@salvo980 wrote:The initial file .cpp include other .cpp for use function. How can I include other .o? I must use, for example:
g++ name.o -shared -o libname.sowith the "-L" option?
g++ name.o -shared -o libname.so -L /usr/lib/name2.soIs it right?
Thanks.
That really depends. If you "own" both cpp files, the most easy solution is to simply link the resulting .o files all together in the final link stage by listing them all as input file to the gcc llink command. Otherwise if your name2.so file already exists, you should not really need to do anything special other than making sure that it does exist on the target system and is made known to the "ld" linker through the execution of the ldshared tool.
Unlike Windows where every import has to be resolved at link time, either through an actual function implementation in an object file or through and import library object file that does the dynamic linking at load time, Linux elf shared libraries do not need that. The linker during build of the shared library object file simply assumes that the dynamic loader "ld" will at load time of the shared library object file, resolve the symbols accordingly. For that the shared library object must of course be installed and known to the ld linker on the target system as pointed out above, by copying it to a well known location on the target and by running ldshared to make it known in the ld cache.