请教帮我弄懂这段make之后的代码

软件和网站开发以及相关技术探讨
回复
seafairy
帖子: 14
注册时间: 2009-07-21 22:35
送出感谢: 0
接收感谢: 0

请教帮我弄懂这段make之后的代码

#1

帖子 seafairy » 2010-11-21 9:41

我安装这个库的时候木有问题,它自己测试了一个bench.cpp程序,编译出的bench文
件运行也木有问题
之后,我自己用它编译一个cpp的程序,就会报错了(包括bench.cpp,我试过)
想请教一下怎么解决
或者请哪位能够告诉我它在编译bench.cpp的时候都做了那些事情呢,谢谢
如下为库编译好之后测试bench.cpp的代码:
make[2]: Entering directory `/home/eecs/Desktop/meepinstall/meep-0.10/tests'
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../src -O2 -malign-double -march=pen
tium4 -MT bench.o -MD -MP -MF ".deps/bench.Tpo" -c -o bench.o bench.cpp; \
then mv -f ".deps/bench.Tpo" ".deps/bench.Po"; else rm -f ".deps/bench.Tpo";
exit 1; fi
/bin/bash ../libtool --tag=CXX --mode=link g++ -O2 -malign-double -march=pen
tium4 -o bench bench.o ../src/libmeep.la -lhdf5 -lz -lharminv -llapack -lb
las -lm -L/usr/lib/gcc/i686-linux-gnu/4.4.5 -L/usr/lib/gcc/i686-linux-gnu/4
.4.5/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/i686-linu
x-gnu/4.4.5/../../.. -L/usr/lib/i686-linux-gnu -lgfortranbegin -lgfortran -lm
-lgcc_s
g++ -O2 -malign-double -march=pentium4 -o bench bench.o ../src/.libs/libmeep
.a /usr/lib/libhdf5.so -lpthread -lz -lharminv -llapack -lblas -L/usr/lib/gcc
/i686-linux-gnu/4.4.5 -L/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib -L/
lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/i686-linux-gnu/4.4.5/../../.. -L/
usr/lib/i686-linux-gnu -lgfortranbegin -lgfortran -lm -lgcc_s
make[2]: Leaving directory `/home/eecs/Desktop/meepinstall/meep-0.10/tests'

如下为我编译一个cpp程序时报错:
eecs@ubuntu:~/Desktop/meepinstall/meep-0.10/tests$ g++ flux.cpp $(pkg-config
--cflags --libs meep)
/usr/local/lib/libblas.a(xerbla.o): In function `xerbla_':
(.text+0x0): multiple definition of `xerbla_'
/usr/local/lib/liblapack.a(xerbla.o):(.text+0x0): first defined here
/usr/local/lib/libhdf5.a(H5.o): In function `H5dont_atexit':
(.text+0xfdc): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5.o): In function `H5check_version':
(.text+0x1049): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5.o): In function `H5_term_library':
(.text+0x132c): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5.o): In function `H5close':
(.text+0x1d58): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5.o): In function `H5open':
(.text+0x231b): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5.o):(.text+0x23db): more undefined references to `
pthread_once' follow
/usr/local/lib/libhdf5.a(H5E.o): In function `H5E_push':
(.text+0x268): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5E_push':
(.text+0x2a8): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5E_dump_api_stack':
(.text+0x351): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5E_dump_api_stack':
(.text+0x391): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5E_clear':
(.text+0x3c1): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5E_clear':
(.text+0x401): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eget_auto':
(.text+0x453): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eget_auto':
(.text+0x495): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eget_auto':
(.text+0x4d5): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eget_auto':
(.text+0x566): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eget_auto':
(.text+0x5a6): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eget_auto':
(.text+0x5bb): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eget_auto':
(.text+0x5fb): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eset_auto':
(.text+0x6c1): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eset_auto':
(.text+0x703): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eset_auto':
(.text+0x743): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eset_auto':
(.text+0x7d4): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eset_auto':
(.text+0x814): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eset_auto':
(.text+0x829): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eset_auto':
(.text+0x869): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5E_walk':
(.text+0x91d): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5E_walk':
(.text+0x95d): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eclear':
(.text+0xa03): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eclear':
(.text+0xa45): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eclear':
(.text+0xa85): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Epush':
(.text+0xb52): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Epush':
(.text+0xb94): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Epush':
(.text+0xbd4): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Epush':
(.text+0xc65): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Epush':
(.text+0xca5): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eprint':
(.text+0xd5b): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eprint':
(.text+0xd9b): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eprint':
(.text+0xdaf): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eprint':
(.text+0xdf1): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Eprint':
(.text+0xe31): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Ewalk':
(.text+0xf68): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Ewalk':
(.text+0xfaa): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5E.o): In function `H5Ewalk':
(.text+0xfea): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5F.o): In function `H5Fget_name':
(.text+0x1824): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5F.o): In function `H5Fget_filesize':
(.text+0x1ac7): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5F.o): In function `H5Fget_freespace':
(.text+0x1cb0): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5F.o): In function `H5Fget_create_plist':
(.text+0x23b2): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5F.o): In function `H5Fclose':
(.text+0x2eeb): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5F.o):(.text+0x348e): more undefined references to
`pthread_once' follow
/usr/local/lib/libhdf5.a(H5TS.o): In function `H5TS_cancel_count_dec':
(.text+0xd): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5TS.o): In function `H5TS_cancel_count_inc':
(.text+0x46): undefined reference to `pthread_getspecific'
/usr/local/lib/libhdf5.a(H5TS.o): In function `H5TS_cancel_count_inc':
(.text+0xb7): undefined reference to `pthread_setspecific'
/usr/local/lib/libhdf5.a(H5TS.o): In function `H5TS_first_thread_init':
(.text+0x24d): undefined reference to `pthread_key_create'
/usr/local/lib/libhdf5.a(H5TS.o): In function `H5TS_first_thread_init':
(.text+0x261): undefined reference to `pthread_key_create'
/usr/local/lib/libhdf5.a(H5TS.o): In function `H5TS_first_thread_init':
(.text+0x275): undefined reference to `pthread_key_create'
/usr/local/lib/libhdf5.a(H5Z.o): In function `H5Zget_filter_info':
(.text+0x837): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5Z.o): In function `H5Zfilter_avail':
(.text+0x986): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5Z.o): In function `H5Zregister':
(.text+0xb38): undefined reference to `pthread_once'
/usr/local/lib/libhdf5.a(H5Z.o): In function `H5Zunregister':
(.text+0x1b17): undefined reference to `pthread_once'
collect2: ld returned 1 exit status
geniushui
帖子: 3
注册时间: 2008-01-25 23:12
送出感谢: 0
接收感谢: 0

Re: 请教帮我弄懂这段make之后的代码

#2

帖子 geniushui » 2010-11-21 16:59

编译选项加上-lpthread
seafairy
帖子: 14
注册时间: 2009-07-21 22:35
送出感谢: 0
接收感谢: 0

Re: 请教帮我弄懂这段make之后的代码

#3

帖子 seafairy » 2010-11-22 8:59

谢谢,问题已解决
头像
thelover
帖子: 47
注册时间: 2008-09-03 16:16
来自: 江湖
送出感谢: 3 次
接收感谢: 0
联系:

Re: 请教帮我弄懂这段make之后的代码

#4

帖子 thelover » 2010-12-14 13:45

:em11 涉及到线程知识的gcc后面得加 -lpthread
回复

回到 “软件/网站开发”