Just a short memo what I found about building shared libraries on Interix, mostly extracted from libtool 1.5.22, file libtool.m4:
The good news: If a package uses libtool 1.5.22 to build the shared libraries, all will work automagically. Only make sure the architecture string contains "interix3", such as "i586-pc-interix3.5", as libtool matches for "interix3*". Use configure option --build to override on SUA:
$ ./configure --build=i586-pc-interix3.5
If you want to or must compile manually:
1) Compile without -fPIC, because -fPIC doesn't work on Interix. It's said to generate broken code.
2a) To simply link a shared lib, use
$ gcc -shared -o lib.so *.o
2b) To include $SONAME as soname in the lib, add gcc option -Wl,-h,$SONAME
Don't use linker option --soname (note the double dash) as on Linux, it does not work on Interix.
$ gcc -shared -Wl,-h,$SONAME ...
2c) If you use the dlopen linker option --export-dynamic for linking on Linux, translate that to -E on Interix.
$ gcc -shared -Wl,-E ...
2d) For hardcoding library names use linker option -rpath $LIBDIR instead of --rpath on Linux:
$ gcc -shared -Wl,-rpath,$LIBDIR ...
2e) For optimizing the loading time you may add a random --image-base, libtool uses:
$ gcc -shared -Wl,--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` ...
3) make sure the resulting *.so* file is executable, otherwise Interix's dynamic linker /lib/ld.so.1 cannot load it:
$ chmod a+x *.so*
4) look if the soname has been set correctly with:
$ objdump -p lib.so
Bottom line: use libtool!
|