I'm trying to link C++ code into a shared object for use as a Python module. I'm using libtool to do the linking. On Linux this works well, but on OpenBSD it fails with lots of C++ library symbols not found.
The problem seems to be that on OpenBSD the shared object doesn't pull in libstdc++. Python isn't written in C++, so doesn't pull in libstdc++ either. I've found that if I explicitly link with -lstdc++ then it works on OpenBSD, which supports this theory. I could potentially just always explicitly link with -lstdc++, but I'm concerned that this could try to link in two different versions on a machine with multiple compilers installed. Comparing the generated libtool scripts on the 2 systems, I've noticed that postdeps is empty on OpenBSD. On Linux it is: postdeps="-lstdc++ -lm -lgcc -lc -lgcc" So this would seem to be on the right track. I don't entirely follow the logic which generates this, but it seems to come from the output of something like: g++ -shared -v /dev/null 2>&1|grep "\-L" On an x86 Linux box (Debian unstable) with g++ 3.3.6 this gives: /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/collect2 --eh-frame-hdr -m elf_i386 -shared /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/../../../crti.o /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/crtbeginS.o -L/usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6 -L/usr/bin/../lib/gcc-lib -L/usr/lib/gcc-lib/i486-linux-gnu/3.3.6 -L/usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/../../.. -L/usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../.. /dev/null -lstdc++ -lm -lgcc_s -lc -lgcc_s /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/crtendS.o /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/../../../crtn.o On an x86 OpenBSD 3.7 box with g++ 3.3.5 this gives: /usr/lib/gcc-lib/i386-unknown-openbsd3.7/3.3.5/collect2 --eh-frame-hdr -shared -Bdynamic -dynamic-linker /usr/libexec/ld.so /usr/lib/crtbeginS.o -L/usr/lib/gcc-lib/i386-unknown-openbsd3.7/3.3.5 /dev/null -lsupc++ -lgcc -lgcc /usr/lib/crtendS.o Note: -lsupc++ instead of -lstdc++. If I remove the "-shared" on OpenBSD I get -lstdc++ instead of -lsupc++. I don't know if it's relevant, but both systems have shared and static versions of libstdc++, but only static versions of libsupc++ and libgcc. The Linux system has a shared (only) libgcc_s, but the OpenBSD system doesn't have this at all. Is this a libtool issue, or should I be looking elsewhere? And please say if I need to provide more information. I don't have a small example showing the problem, though I can work on one if that's helpful. Cheers, Olly _______________________________________________ http://lists.gnu.org/mailman/listinfo/libtool