未定义对符号“pthread_create@@GLIBC_2.2.5"的引用 [英] Undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'

查看:66
本文介绍了未定义对符号“pthread_create@@GLIBC_2.2.5"的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚拉了一个 git 存储库,我和我的朋友正在其中开发一个应用程序.当我运行 ma​​ke 时,我遇到了这个错误:

I just pulled a git repository in which me and my friends are developing an application. When I am running make I am facing this error:

未定义对符号'pthread_create@@GLIBC_2.2.5'的引用/lib/x86_64-linux-gnu/libpthread.so.0:添加符号时出错:DSO命令行 collect2 丢失:错误:ld 返回 1 个退出状态Makefile:182: 目标bin/release/ns"的配方失败 make[1]:*[bin/release/ns] 错误 1 ​​Makefile:133: 目标 'release' 的配方制作失败:* [发布] 错误 2

undefined reference to symbol 'pthread_create@@GLIBC_2.2.5' /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status Makefile:182: recipe for target 'bin/release/ns' failed make[1]: * [bin/release/ns] Error 1 Makefile:133: recipe for target 'release' failed make: * [release] Error 2

我的朋友拉了同一个分支,他运行它没有任何问题.

my friend pulled the same branch and he runs it without any problem.

你能给我一些关于修复的提示吗?详细的回答将不胜感激.

Could you please give me some hints about the fix? Detailed answer would be highly appreciated.

推荐答案

我一直在研究多平台游戏引擎,但我只在 Linux 上遇到了同样的问题.如果您使用 cmake,请将以下内容添加到您的 cmake 文件中:

I've been working on a multi-platform game engine and I faced same issue only on Linux. If you are using cmake add following to your cmake file:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")

如果您不使用 cmake,则需要手动为编译器添加此标志.

If you are not using cmake you need to add this flag for your compiler manually.

在linux系统中使用线程的完整cmake必须包含以下命令:

The complete cmake for using threads in linux systems must contain following commands:

      set(CMAKE_THREAD_LIBS_INIT "-lpthread")
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
      set(CMAKE_HAVE_THREADS_LIBRARY 1)
      set(CMAKE_USE_WIN32_THREADS_INIT 0)
      set(CMAKE_USE_PTHREADS_INIT 1)
      set(THREADS_PREFER_PTHREAD_FLAG ON)

注意:此修复程序也适用于 Mac-O,但有一个区别.您不需要将 -pthread 作为编译器标志传递

Note: Also this fix works for Mac-Os but with one difference. You don't need to pass -pthread as compiler flag

这篇关于未定义对符号“pthread_create@@GLIBC_2.2.5"的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆