2011-01-19 34 views
1

我在这里的集群上成功地用C++编译了一个带boost的程序。我需要运行一个SGE脚本来运行模拟。我得到的错误是这个在集群中加载库

./main:错误而载入共享 库:libboost_thread.so.1.45.0: 无法打开共享对象文件:没有 这样的文件或目录

启动程序时是否需要指定库的名称?我使用的脚本如下

#!/bin/sh 
# (c) 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. 
# This is a simple example of a SGE batch script 

# request Bourne shell as shell for job 
#$ -S /bin/sh 

#$ -N cr_number  # this name shows in qstat 
#$ -S /bin/bash  # run with this shell 
#$ -l h_rt=50:00:00 # need 50 hour runtime 
#$ -pe mpich 4  # define parallel env 
#$ -cwd  # run the job in the directory specified. 
#$ -o cr_number.out 
#$ -e cr_number.err 
# (-j will merge stdout and stderr) 

#$ -notify 
#$ -M [email protected] - send mail about this job to the given email address. 
#$ -m beas   # send a mail to owner when the job 
#      begins (b), ends (e), aborted (a), 
#      and suspended(s).   and suspended(s). 

./main 

谢谢

+0

你是怎么建立`main`的? – 2011-01-19 19:52:54

回答

2

最简单的方法是编译静态二进制。 (随着gcc,使用-static对于其他的编译器,RTFM。)

另一种选择是将LD_LIBRARY_PATH环境变量设置为目录包含Boost库,作业脚本里面:

LD_LIBRARY_PATH=/where/ever/you/installed/boost 

如果你没不要安装Boost,你可以通过ldd main找到你的程序在哪里寻找它的库。

+0

我对这个愚蠢的问题表示歉意,但是我只是在它的结尾指定了-static?通过发布此:gcc -Wall -o main main.cpp Graph.cpp Simulate.cpp -lm -I ../ boost_1_45_0/-L ../ boost_1_45_0/stage/lib/-lboost_thread -static 我得到了一个巨大的数字错误行......谢谢 – Bob 2011-01-19 20:05:44

+0

我认为你需要在`-l`选项之前加上`-static`。如果它不起作用,请尝试设置`LD_LIBRARY_PATH`。首先在您的前端节点上尝试`LD_LIBRARY_PATH = ../boost_1_45_0。/ main`。 – 2011-01-19 20:08:26

0

你在哪个平台上运行SGE?所有的节点都是相同的架构吗?你正在使用哪种编译器?该库需要存在,在您要运行的每个节点上的相同位置。 @larsmans建议的选项可能是最好的想法(运行静态编译的二进制文件)。