Build Issues with pthreads

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Build Issues with pthreads

Kailas Narendran-4
Hi, I'm having problems linking pthreads into my application.
I'm developing an API for some hardware I've made.  If I compile
everything and link the pthreads library, everything works:

(this works)

g++ -D __WIN32__ -Ic:/progra~1/kvaser/canlib/inc -I. -I../Common
-I../XitomeMCBAPI ../Common/DynamicSmoothTrajectory.cpp
../XitomeMCBAPI/FunctionGeneratorNode.cpp
../XitomeMCBAPI/XitomeMCBNode.cpp ../XitomeMCBAPI/XitomeMCBNet.cpp
../Common/CommandList.cpp ../Common/CommandNode.cpp
../Common/CANCommon.cpp ../Common/Delay.cpp ../Common/Kbhit.cpp
../Common/ParseCMDLine.cpp ../Common/UtilityTimer.cpp XiHome.cpp
../Common/lib/libpthreadGC2.a ../XitomeMCBAPI/libxitomemcb.a
-lcanlib32 -lm  -Lc:/progra~1/kvaser/canlib/lib/ms -L.
-L..\XitomeMCBAPI -o XiHome

this is a bit slow and doesn't lend itself to really making an easy to
use API, so i'm trying to compile everything to a library that can be
linked into projects using my hardware (and software API).

to do this, i compile my sources to objects and link them into a
library [1].  When i do so, i get the error:

g++ -o XiHome XiHome.o ../Common/lib/libpthreadGC2.a ../XitomeMCBAPI/libxitomemc
b.a -lcanlib32 -lm -Lc:/progra~1/kvaser/canlib/lib/ms -L.
../XitomeMCBAPI/libxitomemcb.a(XitomeMCBNet.o):XitomeMCBNet.cpp:(.text+0xae3): u
ndefined reference to `pthread_exit'
collect2: ld returned 1 exit status
make[1]: *** [XiHome] Error 1

This works fine under linux.

I've looked around the mailing list archive and saw that others were
having similar issues with undefined references and I've tried
defining both PTW32_EXTERN as well as PTW32_STATIC_LIB (if i use
PTW32_EXTERN the error is _imp__pthread_exit)

anyone know what i'm doing wrong?

thanks!

-kailas

1 -

make -C Common all
make[1]: Entering directory `C:/xitome/MCB/Software/Common'
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o DynamicSmoothTrajectory.o DynamicSmoothTrajectory.c
pp
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o CommandList.o CommandList.cpp
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o CommandNode.o CommandNode.cpp
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o CANCommon.o CANCommon.cpp
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o Delay.o Delay.cpp
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o Kbhit.o Kbhit.cpp
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o ParseCMDLine.o ParseCMDLine.cpp
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o UtilityTimer.o UtilityTimer.cpp
make[1]: Leaving directory `C:/xitome/MCB/Software/Common'
make -C XitomeMCBAPI all
make[1]: Entering directory `C:/xitome/MCB/Software/XitomeMCBAPI'
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o FunctionGeneratorNode.o FunctionGeneratorNode.cpp
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o XitomeMCBNode.o XitomeMCBNode.cpp
g++ -D __WIN32__ -D PTW32_STATIC_LIB -Ic:/progra~1/kvaser/canlib/inc -I. -I../Co
mmon -I../XitomeMCBAPI -c -o XitomeMCBNet.o XitomeMCBNet.cpp
ar -cvq libxitomemcb.a FunctionGeneratorNode.o XitomeMCBNode.o XitomeMCBNet.o ..
/Common/DynamicSmoothTrajectory.o ../Common/CommandList.o ../Common/CommandNode.
o ../Common/CANCommon.o ../Common/Delay.o ../Common/Kbhit.o ../Common/ParseCMDLi
ne.o ../Common/UtilityTimer.o
a - FunctionGeneratorNode.o
a - XitomeMCBNode.o
a - XitomeMCBNet.o
a - ../Common/DynamicSmoothTrajectory.o
a - ../Common/CommandList.o
a - ../Common/CommandNode.o
a - ../Common/CANCommon.o
a - ../Common/Delay.o
a - ../Common/Kbhit.o
a - ../Common/ParseCMDLine.o
a - ../Common/UtilityTimer.o
make[1]: Leaving directory `C:/xitome/MCB/Software/XitomeMCBAPI'
make -C Utilities all
make[1]: Entering directory `C:/xitome/MCB/Software/Utilities'
g++ -o XiHome XiHome.o ../Common/lib/libpthreadGC2.a ../XitomeMCBAPI/libxitomemc
b.a -lcanlib32 -lm -Lc:/progra~1/kvaser/canlib/lib/ms -L.
make[1]: Leaving directory `C:/xitome/MCB/Software/Utilities'
Reply | Threaded
Open this post in threaded view
|

Fwd: Build Issues with pthreads

Kailas Narendran-4
Thanks for the reply.

I ended up getting it to work, but I'm not sure why.

I ultimately got rid of explicitly providing the library on the
command line to the compiler and instead used:

-lpthreadGC2

as an argument to g++, and everything works.

can anyone tell me what the difference is?

-kailas