LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 865|回复: 2

请教:configure的时候,如何使用-lpthread的选项?

[复制链接]
发表于 2010-5-17 23:09:19 | 显示全部楼层 |阅读模式
各位高手,兄弟最近在sled11上编译bochs:
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes


在make的时候,

undefined reference to `pthread_create'
collect2: ld returned 1 exit status
make: *** [bochs] 错误 1


请问怎么在configure的时候加上pthread的库?
谢谢
发表于 2010-5-18 11:19:14 | 显示全部楼层
网上找到的,我试了一下,可以解决:

当启用bochs 的debugger时,配置./configure --enable-debugger后make就出现下面的错误:

gui/libgui.a(gtk_enh_dbg_osdep.o): In function `MakeGTKthreads()':
/home/bcos/Desktop/bochs-test/bochs-2.4.pre1/gui/gtk_enh_dbg_osdep.cc:2120: undefined reference to `pthread_create'
collect2: ld returned 1 exit status
make: *** [bochs] Error 1

解决方法1:修改"Makefile.in" 92 和 93行 为 "CC = @CC@ -pthread" and "CXX = @CXX@ -pthread"

解决方法2:在Makefile.in中183行

bochs@EXE@: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \
cpu/libcpu.a memory/libmemory.a gui/libgui.a \
@DISASM_VAR@ @INSTRUMENT_VAR@ $(BX_OBJS) \
$(SIMX86_OBJS) @FPU_VAR@ @GDBSTUB_VAR@ @PLUGIN_VAR@
@LINK@ @EXPORT_DYNAMIC@ $(BX_OBJS) $(SIMX86_OBJS) \
@IODEV_LIB_VAR@ @DEBUGGER_VAR@ cpu/libcpu.a memory/libmemory.a gui/libgui.a \
@DISASM_VAR@ @INSTRUMENT_VAR@ @PLUGIN_VAR@ \
@GDBSTUB_VAR@ @FPU_VAR@ \
@NONPLUGIN_GUI_LINK_OPTS@ \
$(MCH_LINK_FLAGS) \
$(SIMX86_LINK_FLAGS) \
$(READLINE_LIB) \
$(EXTRA_LINK_OPTS) \
$(LIBS)

在最后$(LIBS)后面加上 \ -lpthread如下:

bochs@EXE@: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \
cpu/libcpu.a memory/libmemory.a gui/libgui.a \
@DISASM_VAR@ @INSTRUMENT_VAR@ $(BX_OBJS) \
.
.
.
$(LIBS)\
-lpthread

即可编译通过。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-5-18 21:24:51 | 显示全部楼层
多谢多谢,我也在网上搜了一下,没有找到这个,非常感谢!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表