Question : First try at a Linux shared library

I've read a bunch of documents online and have them printed out right here. I'm trying to port a pretty simple Windows DLL to a .so shared library on Linux, that will be dynamically loaded. It is a single object file. I have compiled it using the -fPIC option and linked it to get a .so made.

However, when I try to dynamically load it in my program, dlopen() returns NULL. I have verified the path I am giving it is correct; it is a full path.

The only thing I can think of is that my .so library I am building depends on another .so. I'm using functions in a .so library called 'libvshm.so' that exists in another directory. The compile is fine so I know the headers are being found fine.

When I try 'ldd' on my shared library, all I get is:

libgcc_s.so.1
libc.so.6
/lib/ld-linux.so.2

It doesn't list the libvshm.so that it should also be using?? Do I need to pass something on the link line that I'm not.

My compile line:
gcc -fPIC -g -c -Wall VtsPlugin.cxx

My link line:
gcc -shared -Wl,-soname,libSharedMemory.so.1 -o libSharedMemory.so.1 VtsPlugin.o

Is there also a way to get more error information on what else may be going wrong, instead of just guessing?

Thanks

Answer : First try at a Linux shared library

To find out the reason why dlopen returns NULL, try to call dlerror, e.g. this way:

fprintf(stderr, "%s\n", dlerror());


Ldd shows nothing about external library absolutelly correct, because you link external library also dynamically. This means that all dependencies in your library will be resolved by dynamic linker when you load your library.
Random Solutions  
 
programming4us programming4us