简体   繁体   English

如何在集群上链接 boost 库?

[英]How can I link boost library on cluster?

I have program which works well on my computer with following command我的程序可以通过以下命令在我的计算机上运行良好

g++ -o result source.cpp -lboost_program_options

However, this command doesn't work on the cluster where the boost library is such但是,此命令在 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"

I have searched how to solve this problem for a while, but haven't found one works for me.我已经搜索了一段时间如何解决这个问题,但没有找到适合我的方法。

Thank you.谢谢你。

You need to specify the path to where the compiler can find the include files and libraries, since they're installed in a non-default path.您需要指定编译器可以找到包含文件和库的路径,因为它们安装在非默认路径中。

Most likely something like this, after loading the module for boost (that's "minus capital i" for include files and "minus capital L" for libraries):最有可能是这样的,加载模块进行 boost 之后(对于包含文件,“减去大写 i”,对于库,“减去大写 L”):

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

Alternatively, you can update the $CPATH and $LIBRARY_PATH environment variables (actually, the module file should probably be doing that for you):或者,您可以更新$CPATH$LIBRARY_PATH环境变量(实际上,模块文件可能应该为您执行此操作):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM