Ubuntu下编译程序是出现pthread_create未定义错误
2014-02-10 17:06
465 查看
gcc -c node_list.c -o node_list.o gcc -lpthread sim.o cli.o list.o node_list.o -o sim.exe sim.o: In function `sim_add_node': sim.c:(.text+0xa55): undefined reference to `pthread_create' sim.c:(.text+0xa8a): undefined reference to `pthread_create' sim.o: In function `sim_kill_nodes': sim.c:(.text+0xb5a): undefined reference to `pthread_kill' cli.o: In function `kill_node': cli.c:(.text+0x4ec): undefined reference to `pthread_kill' cli.c:(.text+0x512): undefined reference to `pthread_kill' collect2: ld returned 1 exit status make: *** [sim.exe] Error 1
百思不得其姐。。。
最后在这里看到了,泪流满面啊。(-l包含库指令的位置要在最后!!)
换了位置之后
gcc sim.o cli.o list.o node_list.o -o sim.exe -lpthread cp sim.exe ../test/test_sim
可以了。
实际上,这可能不是这么简单地将该指令放在最后这么简单。这或许是涉及到lpthread和pthread的用法问题,请参考网友的文章。
http://chaoslawful.iteye.com/blog/568602
相关文章推荐
- 编译Linux程序出现“对‘pthread_create’未定义的引用”
- Ubuntu下使用Eclipse编译pthread程序错误undefined reference to `pthread_create'
- linux编译出现undefined reference to symbol 'pthread_create错误解决方案
- gcc 编译出现undefined reference to‘pthread_create’的错误
- ubuntu16.04下编译qt5。5程序出现:-1: error: [ui_firstpage.h] Error 1 错误的解决
- ubuntu安装多个qt版本--不同qt版本编译同一个程序时出现错误--解决方案
- 在liunx编译C语言程序出现Undefined reference to pthread_create in Linux 错误*
- liunx 下多线程编译时出现对‘pthread_create’未定义的引用
- ubuntu 编译 Android 出现的若干错误及解决方法
- 在ubuntu下编译opencv程序后,执行报下面到错误: error while loading shared libraries: libopencv_core.so.2.4: cannot op
- 安装完JDK后无法编译JAVA程序出现java.lang.NoClassDefFoundError错误提示
- Ubuntu15.04 QT5编译出现cannot find -lGL 和 collect2:error:ld returned 1 exit status 错误
- WPF编译时出现【程序“\MVC_DHCC.exe”不包含适合于入口点的静态“Main”方法】的错误
- BUG:Visual Studio 6.0 中出现错误消息“Setup Was Unable to Create a DCOM User Account”(安装程序无法创建 DCOM 用户帐户)
- 编译c文件出现的小bug--错误:程序中有游离的'\302'
- 在64位 ubuntu下编译wine1.8.1出现错误的解决
- Ubuntu 12.04下用g++编译cplex实例程序,配置、出现的问题,解决办法
- 编译和链接 - 解决出现的LNK2005“符号已定义”错误 2
- C程序访问hadoop出现的各种编译错误和运行时各种类DefFound异常的解决方法(makefile的书写和环境变量的配置)
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题