Which lib for pthreads?

Jonathon McKitrick jcm at FreeBSD-uk.eu.org
Sun Mar 6 13:55:04 PST 2005


On Sun, Mar 06, 2005 at 11:39:55PM +0200, Giorgos Keramidas wrote:
: On 2005-03-06 21:32, Jonathon McKitrick <jcm at FreeBSD-uk.eu.org> wrote:
: >On Sat, Mar 05, 2005 at 07:18:31PM -0600, Dan Nelson wrote:
: >:In the last episode (Mar 05), Jonathon McKitrick said:
: >:> Linux lets me use -pthread, but under BSD I get 'undefined symbol
: >:> "pthread_mutex_lock."'
: >:>
: >:> What's the correct linker syntax for pthreads?
: >:
: >: That would be it.  It should work on 4.* and 5.*.
: >
: > I found -lc_r does the trick.  Not what I was expecting.
: 
: -lpthread should work too.

Hmmmm...

jcm at worker:...cvs/tcontainer/libplugina> make install
cc -O -pipe -Wall -g -I.. -I../include -shared -fPIC -c plugina.c
c++  -O -pipe -Wall -g -I.. -I../include -shared -fPIC -c wrapper.cpp
c++  -O -pipe -Wall -g -I.. -I../include -shared -fPIC -c myclass.cpp
cc -O -pipe -Wall -g -I.. -I../include -shared -fPIC -c threads.c
cc -O -pipe -Wall -g -I.. -I../include -shared -fPIC  -lpthread -lstdc++ -g
-Wl,-soname,libplugina.so.0 -o libplugina.so.0.0 plugina.o wrapper.o
myclass.o threads.o
/usr/libexec/elf/ld: cannot find -lpthread
*** Error code 1

Stop in /usr/home/jcm/cvs/tcontainer/libplugina.
jcm at worker:...cvs/tcontainer/libplugina> 

What about -pthread?

jcm at worker:...cvs/tcontainer/libplugina> make install
cc -O -pipe -Wall -g -I.. -I../include -shared -fPIC -c plugina.c
c++  -O -pipe -Wall -g -I.. -I../include -shared -fPIC -c wrapper.cpp
c++  -O -pipe -Wall -g -I.. -I../include -shared -fPIC -c myclass.cpp
cc -O -pipe -Wall -g -I.. -I../include -shared -fPIC -c threads.c
cc -O -pipe -Wall -g -I.. -I../include -shared -fPIC  -pthread -lstdc++ -g
-Wl,-soname,libplugina.so.0 -o libplugina.so.0.0 plugina.o wrapper.o
myclass.o threads.o
---> Installing libplugina.so to /home/jcm/lib
install -m 644 libplugina.so.0.0 /home/jcm/lib
ln -sf libplugina.so.0.0 /home/jcm/lib/libplugina.so.0
ln -sf libplugina.so.0 /home/jcm/lib/libplugina.so
jcm at worker:...cvs/tcontainer/libplugina> app
/usr/libexec/ld-elf.so.1: /home/jcm/lib/libplugina.so: Undefined symbol
"pthread_create"
jcm at worker:...cvs/tcontainer/libplugina> 


Jonathon McKitrick
--
My other computer is your Windows box.


More information about the freebsd-questions mailing list