libxcb.a:未定义的符号引用' XauGetBestAuthByAddr'

时间:2016-01-04 00:49:22

标签: linker cmake

当我输入make时,我得到:

Linking CXX executable ../../bin/MyProgram
/usr/bin/ld: /home/myname/Desktop/MyProject/build/lib/libxcb.a(xcb_auth.o): undefined reference to symbol 'XauGetBestAuthByAddr'
/usr/lib/x86_64-linux-gnu/libXau.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
...

和我的link.txt文件看起来像

/usr/bin/g++    -O3 -O3 -DNDEBUG   CMakeFiles/MyProject.dir/main.cpp.o      
-o ../../bin/MyProject  -L/home/myname/Desktop/MyProject/build/lib -rdynamic -lboost_thread-mt -lboost_date_time-mt -lboost_regex 
-lboost_filesystem-mt -lboost_system-mt -lboost_program_options-mt ../../lib/libfftw3.a   -lXau -lxcb -lXext -lX11 -lpetsc -lmpich -lmpl -lrt ../../lib/libflapack.a 
-lgfortran ../../lib/libfblas.a -lgfortran ../../lib/libMyProjectAPI.a -lfftw3  -lGLU -lGL -lpthread ../../lib/libfftw3.a  -lXau -lxcb -lX11 -lpetsc -lmpich -lmpl -lrt 
../../lib/libflapack.a -lgfortran ../../lib/libfblas.a -lgfortran ../../lib/libfblas.a -lpthread -lboost_thread-mt -lboost_date_time-mt -lboost_regex 
-lboost_filesystem-mt -lboost_system-mt     -lboost_program_options-mt /home/myname/anaconda2/lib/libhdf5.so /home/myname/anaconda2/lib/libhdf5_hl.so 
-lrt /home/myname/anaconda2/lib/libz.so -ldl -lm /home/myname/anaconda2/lib/libhdf5_cpp.so 
/home/myname/anaconda2/lib/libhdf5_hl_cpp.so /home/myname/anaconda2/lib/libhdf5.so /home/myname/anaconda2/lib/libhdf5_hl.so -lrt /home/myname/anaconda2/lib/libz.so 
-ldl -lm /home/myname/anaconda2/lib/libhdf5_cpp.so /home/myname/anaconda2/lib/libhdf5_hl_cpp.so -Wl,-rpath,/home/myname/Desktop/MyProject/build/lib:/home/myname/anaconda2/lib 

任何人都知道如何解决这个问题?我之前通过将相关的lib文件从/usr/lib/x86_64-linux-gnu复制到home/myname/Desktop/MyProject/build/lib来解决类似的错误。我认为将-lXau从前者复制到后一个目录会有所帮助,但显然不是

1 个答案:

答案 0 :(得分:2)

交换-lXau-lxcb的位置:扫描库以便找到未解析的符号。