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

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

问题描述

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

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:目标发布"的配方 失败的品牌:* [发布]错误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系统中使用线程的完整命令必须包含以下命令:

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天全站免登陆