仅在远程计算机

时间:2017-09-15 01:04:37

标签: c++ c++11 boost

问题:我的文件在我的本地虚拟机(LVM)上编译,但在Institute服务器(IS)上没有编译。

LVM和IS安装了相同版本的Boost库(从源代码安装)。

使用环境变量bashrcPATH LD_LIBRARY_PATH更新Boost文件,如下所示:

在LVM上:

PATH=/home/X/my_lib/boost_1_64_0:$PATH
LD_LIBRARY_PATH=/home/X/my_lib/boost_1_64_0/stage/lib:$LD_LIBRARY_PATH
export PATH 
export LD_LIBRARY_PATH

在IS:

PATH=/user/X/my_lib/boost_1_64_0:$PATH
LD_LIBRARY_PATH=/user/X/my_lib/boost_1_64_0/stage/lib:$LD_LIBRARY_PATH

export PATH
export LD_LIBRARY_PATH

使用以下命令在LVM上编译文件:

g++ -std=c++11 -O3 benchmark_ad_tree.cpp blank_scoring_function.cpp fnml_scoring_function.cpp log_likelihood_calculator.cpp bdeu_scoring_function.cpp bayesian_network.cpp score_calculator.cpp ad_tree.cpp -o check  -L /home/X/my_lib/boost_1_64_0/stage/lib/*.so

但是,当使用相同的命令在IS上编译相同的代码时,它会抛出以下一堆异常:

g++ -std=c++11 -O3 benchmark_ad_tree.cpp blank_scoring_function.cpp fnml_scoring_function.cpp log_likelihood_calculator.cpp bdeu_scoring_function.cpp bayesian_network.cpp score_calculator.cpp ad_tree.cpp -o check  /user/X/my_lib/boost_1_64_0/stage/lib/*.so

更新: 遵循@John Zwinck的建议(在答案部分)。

我已将编译命令更新为

提出的例外情况:

g++ -std=c++11 -O3 benchmark_ad_tree.cpp blank_scoring_function.cpp fnml_scoring_function.cpp log_likelihood_calculator.cpp bdeu_scoring_function.cpp bayesian_network.cpp score_calculator.cpp ad_tree.cpp -o check -L /user/X/my_lib/boost_1_64_0/stage/lib -lboost_numpy -lboost_python  -lboost_thread

提出异常:

/usr/bin/ld: /tmp/ccWojrSj.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/user/X/my_lib/boost_1_64_0/stage/lib/libboost_system.so.1.64.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

1 个答案:

答案 0 :(得分:0)

您使用了错误的链接器参数:

-L /home/X/my_lib/boost_1_64_0/stage/lib/*.so

应该是:

-L /home/X/my_lib/boost_1_64_0/stage/lib -l boost_numpy -l boost_python

没有必要将Boost加入PATH,除非作为最后的手段,否则不应设置LD_LIBRARY_PATH

永远不要将shell通配符(*)用作构建命令的一部分。