gpt4 book ai didi

gcc - gcc 和 pthreads 的 undefined reference 错误 _dl_stack_flags

转载 作者:行者123 更新时间:2023-12-04 16:21:17 26 4
gpt4 key购买 nike

尝试在 Ubuntu 上使用 pthreads 编译应用程序时出现以下错误:

/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版本是:

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 版本是:

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)

构建命令是:

/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'

以前有人解决过这个问题吗?

最佳答案

Ask Ubuntu 上也有人问过这个问题.

简而言之,问题似乎是由于试图将 libpthread 与动态 libc 进行静态链接。动态链接 libpthread 应该会使错误消失,我怀疑如果 libpthreadlibc 都是静态链接的,错误也会消失。

关于gcc - gcc 和 pthreads 的 undefined reference 错误 _dl_stack_flags,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5738000/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com