Undefined reference error _dl_stack_flags with gcc and pthreads

回眸只為那壹抹淺笑 提交于 2021-01-28 04:31:07

问题


I get the following error when trying to compile an application using pthreads on Ubuntu:

/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libpthread.a(pthread_create.o): In function `allocate_stack':
/build/buildd/eglibc-2.11.1/nptl/allocatestack.c:444: undefined reference to `_dl_stack_flags'

Ubuntu version is:

wade@wadesworld:~$ uname -a
Linux wadesworld 2.6.18-194.8.1.el5.028stab070.5ent #1 SMP Fri Sep 17 19:46:02 MSD 2010 i686 GNU/Linux

gcc version is:

wade@wadesworld:~$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)

Build command is:

/usr/bin/cmake -E cmake_link_script CMakeFiles/vtest.dir/link.txt
--verbose=1 /usr/bin/c++      CMakeFiles/vtest.dir/certificate.cc.o
CMakeFiles/vtest.dir/client.cc.o CMakeFiles/vtest.dir/vinterface.cc.o
CMakeFiles/vtest.dir/vuser.cc.o CMakeFiles/vtest.dir/config.cc.o
CMakeFiles/vtest.dir/vinterface.cc.o CMakeFiles/vtest.dir/vuser.cc.o
CMakeFiles/vtest.dir/vtest.cc.o CMakeFiles/vtest.dir/interface.cc.o
CMakeFiles/vtest.dir/auth.cc.o CMakeFiles/vtest.dir/main.cc.o
CMakeFiles/vtest.dir/manage.cc.o CMakeFiles/vtest.dir/md5.c.o
CMakeFiles/vtest.dir/mm.cc.o CMakeFiles/vtest.dir/mysqldb.cc.o
CMakeFiles/vtest.dir/process.cc.o CMakeFiles/vtest.dir/server.cc.o
CMakeFiles/vtest.dir/vinterface.cc.o CMakeFiles/vtest.dir/server_instance.cc.o
CMakeFiles/vtest.dir/support.cc.o CMakeFiles/vtest.dir/sysinterface.cc.o
CMakeFiles/vtest.dir/vsuser.cc.o CMakeFiles/vtest.dir/user.cc.o
-o vtest -rdynamic -L/home/wade/vtest/external_dependencies/lin/lib
-Wl,-Bstatic -lmysqlclient -lsqlite3 -lpthread -Wl,-Bdynamic -ldl
-Wl,-Bstatic -lcrypt -Wl,-Bdynamic
-Wl,-rpath,/home/wade/vtest/external_dependencies/lin/lib
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libpthread.a(
pthread_create.o): In function `allocate_stack':
/build/buildd/eglibc-2.11.1/nptl/allocatestack.c:444: undefined
reference to `_dl_stack_flags'

Has anyone solved this problem before?


回答1:


This question was also asked on Ask Ubuntu.

In short, the problem appears to be due to trying to statically link libpthread against a dynamic libc. Dynamically linking libpthread should make the error go away, and I suspect that the error would also go away if both libpthread and libc were statically linked.



来源:https://stackoverflow.com/questions/5738000/undefined-reference-error-dl-stack-flags-with-gcc-and-pthreads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!