dlopen failing on library with statically linked dependencies


 
Thread Tools Search this Thread
Top Forums Programming dlopen failing on library with statically linked dependencies
# 1  
Old 06-28-2010
dlopen failing on library with statically linked dependencies

I am attempting to port a program from OS X to Linux. It's C++ & Qt Creator and I did the original Windows to OS X port, so I tried to make it as POSIX-compliant as possible; the OS X port works well, and the Linux port builds and starts (it's on Ubuntu 9.10) but has some issues running.
The application has a plugin system. Plugins are built along with the main executable, and then are loaded at startup via dlopen. One of these plugins links to VTK and the only thing setting this apart from the various other 3rd-party dependencies is that VTK here is statically linked. When I attempt to dlopen this plugin, or any plugin which depends on that plugin, dlopen throws an error like this:
Quote:
./Plugins/libVirtualCameraImaged.so.1: undefined symbol: _ZN29vtkInformationStringVectorKeyC1EPKcS1_i
The part that perplexes me is that the plugin code itself can compile and link without this error; if I had forgotten a library at compile time, it would never have linked. It's not dynamically linked with VTK, so LD_LIBRARY_PATH is irrelevant and I can't use 'ldd' to see where it's trying to find it. Looking at the build output, I see the "-L/usr/local/lib/vtk-5.6" and "-lvtkCommon" telling me that it has the right path to the right library, and I can look in the output of 'nm libvtkCommon.a' and see the aforementioned symbol:
Quote:
000000d6 T _ZN29vtkInformationStringVectorKeyC1EPKcS1_i
...so I know it is linking with a library that defines that undefined symbol.

Does anyone have any idea what I could be doing wrong in this build to get symptoms like this?
# 2  
Old 06-28-2010
dlopen works only on object code linked PIC. Anything that resolves to an object archive has to have been linked in previously.

Try creating a dummy function, one that you do not call, that has a reference to the required function symbols(s) in the .a file. Also declare variables as extern. This will force the link editor to load the symbol from the archive at link time. nm <myprogram> should show the symbols like _ZN29vtkInformationStringVectorKeyC1EPKcS1_i

That one looks like you need to declare it extern. Does nm show it having an entry point?
# 3  
Old 06-28-2010
Quote:
Originally Posted by jim mcnamara
Try creating a dummy function, one that you do not call, that has a reference to the required function symbols(s) in the .a file. Also declare variables as extern. This will force the link editor to load the symbol from the archive at link time. nm <myprogram> should show the symbols like _ZN29vtkInformationStringVectorKeyC1EPKcS1_i

That one looks like you need to declare it extern. Does nm show it having an entry point?
The issue here is that I really have no idea where the aforementioned symbol is even used. I can't find any references to it in the rather large code (most of which I did not write). Given that it builds and runs on OS X (static library there too), perhaps before making extensive changes to the code I should try building VTK as shared rather than static.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. AIX

Create shared libs on AIX (with certain libs which are statically linked)

I want to create a shared lib with certain libs statically linked to it. I can generate a fully shared lib as follows: gcc -maix64 -DHAVE_CONFIG_H -I. -I./src -DHAVE_OPENSSL -I/usr/include/openssl -I/usr/include -I/usr/include/apr-1 -D_LARGEFILE64_SOURCE -I/usr/java8_64/include -shared -o... (0 Replies)
Discussion started by: amandeepgautam
0 Replies

2. Programming

Dynamic library load with dlopen

Hi, I created two library libsum.so and libproduct.so. In the libproduct.so is defined function "product" that use function "sum" defined in libsum.so. So libproduct depends on libsum. In main function I called product function by a dlopen request. Unfortunaly, when I execute program I have an... (5 Replies)
Discussion started by: shade82
5 Replies

3. UNIX for Advanced & Expert Users

ldd shows the dependencies of library- oracle8i

Hi, ldd -d fgs_bin/la_daemon_flex_pipe libclntsh.so.8.0 => /oracle/app/oracle/product/8.1.7/lib/libclntsh.so.8.0 libnsl.so.1 => /usr/lib/libnsl.so.1 libsocket.so.1 => /usr/lib/libsocket.so.1 libdl.so.1 => /usr/lib/libdl.so.1 ... (3 Replies)
Discussion started by: shafi2all
3 Replies

4. Programming

how to use a dynamical linked library in C++ program in Linux

I have a dynamically linked library, providing some functions needed in my project. I have successfully imported it into my VC ++ 6.0 project. Now, i am translating the project into pure C++ (such as avoiding using MFC classess) in Linux box. Does anyone know if it makes sense to try to use... (2 Replies)
Discussion started by: cy163
2 Replies

5. Programming

Can't dlopen() a library containing Thread Local Storage

Hi, I have a small test c program which tries to dlopen a shared library(libjvm.sl). But i get error as "Can't dlopen() a library containing Thread Local Storage" My program is as below when i run the program i get error any pointers why the error?? I am using hp-ux . The... (1 Reply)
Discussion started by: shriashishpatil
1 Replies

6. Programming

HOw to load dynamic lib from a statically linked program ?

I need to load a dynamic library from a statically linked program. Is there a way without recompiling my program. when i try to do that my program just crashes. If not possible, how can I avoid crashing the program when i try to load the dynamic lib, again without recompiling. If my... (1 Reply)
Discussion started by: disclaimer
1 Replies
Login or Register to Ask a Question