我如何 link 提升集群上的库?

How can I link boost library on cluster?

我的程序在我的电脑上使用以下命令运行良好

g++ -o result source.cpp -lboost_program_options

但是这个命令在boost库所在的集群上不起作用

 #%Module1.0#####################################################################
##
## boost modulefile
##
## boost/1.55.0/gcc-4.4.7
##
proc ModulesHelp { } {
      puts stderr "\tThis module loads boost-1.55.0 environment for aries compute nodes."
      puts stderr ""
      puts stderr "\tBuild script:    /build/gcc-4.4.7/build-boost-1.55.0.sh"
      puts stderr "\tCompilation options:  /build/gcc-4.4.7/BUILD-boost-1.55.0/boost/bbost.v2/config.log"
}
module-whatis   "loads the boost environment for x86_E5v2 CNs"

module load  mvapich2/2.0.1/gcc-4.4.7 python/2.7.9/gcc-4.4.7
conflict boost

# for Tcl script use only
set             version         1.55.0
set             root            /ssoft/boost/1.55.0/RH6/gcc-4.4.7/x86_E5v2/mvapich2

setenv BOOST_ROOT       "${root}"
setenv BOOST_INCLUDE    "${root}/include"
setenv BOOST_LIBRARY    "${root}/lib"
prepend-path    LD_LIBRARY_PATH "${root}/lib"

我已经搜索了一段时间如何解决这个问题,但没有找到适合我的方法。

谢谢。

您需要指定编译器可以找到包含文件和库的路径,因为它们安装在非默认路径中。

很可能是这样的, 加载用于提升的模块之后(对于包含文件是 "minus capital i",对于库是 "minus capital L"):

g++ -o result source.cpp -I$BOOST_INCLUDE -L$BOOST_LIBRARY -lboost_program_options

或者,您可以更新 $CPATH$LIBRARY_PATH 环境变量(实际上,模块文件应该可以为您执行此操作):

export CPATH=$BOOST_INCLUDE:$PATH
export LIBRARY_PATH=$BOOST_LIBRARY:$LIBRARY_PATH
g++ -o result source.cpp -lboost_program_options