1

I am linking an so, that depends on libmxml.so. However I have no rights install libmxml.so.

So thats what I am doing

gcc -shared -m32 -o ServiceProvider.so ServiceProvider.o -L ../../../../system/addonlibs/ -lmxml -lpthread

ldd shows me

ldd ServiceProvider.so 
    libmxml.so.1 => not found
    libpthread.so.0 => /lib/libpthread.so.0 (0x40026000)
    libc.so.6 => /lib/libc.so.6 (0x40046000)

the second try was

gcc -shared -m32 -o ServiceProvider.so ServiceProvider.o ../../../../system/addonlibs/libmxml.so -lpthread

and still ldd shows me

ldd ServiceProvider.so 
    libmxml.so.1 => not found
    libpthread.so.0 => /lib/libpthread.so.0 (0x40026000)
    libc.so.6 => /lib/libc.so.6 (0x40046000)

Consequently, ldd does not find the library, since I only have "libmxml.so", but no "libmxml.so.1". How do I get rid of this ".1" suffix? Why is it comming?

yuan
  • 2,215
  • 1
  • 17
  • 25
Stasik
  • 2,430
  • 1
  • 23
  • 40

1 Answers1

0

When you link with a dynamic library, you should not do :

gcc -shared -m32 -o ServiceProvider.so ServiceProvider.o ../../../../system/addonlibs/libmxml.so -lpthread

Instead, make sure that /yourpath/system/addonlibs (you should use the full path instead of a relative one) is in you LIBRARY_PATH. Then change you link command.

export LIBRARY_PATH=/yourpath/system/addonlibs:$LIBRARY_PATH
gcc -shared -m32 -o ServiceProvider.so ServiceProvider.o -lmxml -lpthread

You can also write that:

gcc -shared -m32 -o ServiceProvider.so ServiceProvider.o -L/yourpath/system/addonlibs -lmxml -lpthread

However, to run your program, you will need to have your library path in LD_LIBRARY_PATH.

If you have issues with .soand .so.1 stuff, then rename your .so to .so.1 and make a symlink from .so.1 to .so.

Edit:

If you do objdump -p libmxml.so | grep SONAME you will probably get libmxml.so.1. It is where you get the libmxml.so.1 identifier.

Matthieu Rouget
  • 3,009
  • 16
  • 22