undefined symbol: _ZL22__gthrw_pthread_cancelm error-Collection of common programming errors
I have a C++/C application which needs to be compiled as a 32 bit application (as there are certain third-party libraries only available for 32 bit). However, the compilation as well as the execution will happen on CentOS 6.4 x86_64 machine.
I am using gnu autotools for building. After doing a lot of googling, finally figured a sets of options to give to ./configure
to create 32 bit executables/shared objects. Set the LD_LIBRARY_PATH
to search in /lib, /usr/lib/, /usr/lib/gcc/...
instead of /lib64, ...
Verified that all the generated .so and executable are 32 bit by using file
command.
But I get the error: “undefined symbol: _ZL22__gthrw_pthread_cancelm
” if I run the executable.
Any clues?
-
It seems you forgot to link to pthreads with
-lpthread
.GCC adds a layer of abstraction over pthreads and this abstraction use weak symbols, so you can build your executable without link error but fail at runtime.
-
Is there a 32bits pthread library on your target host? If not, I guess you need to get one installed. Also inspect the output of
ldd
on your target host, this might help you find out what is missing.
Originally posted 2013-11-09 23:11:31.