Date: Wed, 26 Sep 2007 13:47:07 -0400 From: Mikhail Teterin <mi+mill@aldan.algebra.com> To: ports@freebsd.org Cc: nork@freebsd.org Subject: the right way to link pthread into shared libraries? Message-ID: <200709261347.08174.mi%2Bmill@aldan.algebra.com>
next in thread | raw e-mail | index | archive | help
Hello! I was always under the impression, that using ${PTHREAD_LIBS} on compiler's command line would produce a library, which is properly linked with the correct threading implementation. Unfortunately, that does not seem to be the case: /bin/sh /opt/bin/libtool --tag=CXX --mode=link c++ -pipe -O2 -fno-strict-aliasing -pipe -march=opteron -D_THREAD_SAFE -o libIlmThread.la -rpath /opt/lib -version-info 4:0:0 -no-undefined IlmThreadPool.lo IlmThread.lo IlmThreadSemaphore.lo IlmThreadMutex.lo IlmThreadPosix.lo IlmThreadSemaphorePosix.lo IlmThreadSemaphorePosixCompat.lo IlmThreadMutexPosix.lo ../Iex/libIex.la -pthread c++ -shared -nostdlib /usr/lib/crti.o /usr/lib/crtbeginS.o .libs/IlmThreadPool.o .libs/IlmThread.o .libs/IlmThreadSemaphore.o .libs/IlmThreadMutex.o .libs/IlmThreadPosix.o .libs/IlmThreadSemaphorePosix.o .libs/IlmThreadSemaphorePosixCompat.o .libs/IlmThreadMutexPosix.o -Wl,--rpath -Wl,/var/ports/graphics/OpenEXR/work/openexr-1.4.0/Iex/.libs -Wl,--rpath -Wl,/opt/lib ../Iex/.libs/libIex.so -pthread -L/usr/lib -lstdc++ -lm -lgcc_pic /usr/lib/crtendS.o /usr/lib/crtn.o -march=opteron -pthread -pthread -pthread -Wl,-soname -Wl,libIlmThread.so.4 -o .libs/libIlmThread.so.4 (cd .libs && rm -f libIlmThread.so && ln -s libIlmThread.so.4 libIlmThread.so) (cd .libs && rm -f libIlmThread.so && ln -s libIlmThread.so.4 libIlmThread.so) ar cru .libs/libIlmThread.a IlmThreadPool.o IlmThread.o IlmThreadSemaphore.o IlmThreadMutex.o IlmThreadPosix.o IlmThreadSemaphorePosix.o IlmThreadSemaphorePosixCompat.o IlmThreadMutexPosix.o ranlib .libs/libIlmThread.a creating libIlmThread.la (cd .libs && rm -f libIlmThread.la && ln -s ../libIlmThread.la libIlmThread.la) mi@aldan:work/openexr-1.4.0/IlmThread (1403) ldd .libs/libIlmThread.so.4 .libs/libIlmThread.so.4: libIex.so.4 => /var/ports/graphics/OpenEXR/work/openexr-1.4.0/Iex/.libs/libIex.so.4 (0x800943000) libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x800a59000) libm.so.4 => /lib/libm.so.4 (0x800c50000) Although `-pthread' can be seen several times on the command line, the resulting executable is NOT linked with libpthread.so and the pthread_* functions called from the library are left undefined... Please, advise. Thanks! -mi
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709261347.08174.mi%2Bmill>