2009-10-08 48 views
2

我正在開發HPC。在那個HPC上安裝了舊版本的Boost,並且該增強庫沒有Boost.MPI。我請求管理員將其安裝在HPC上。但他們要求我將它安裝在我的主目錄中。所以我在主目錄上安裝了boost和boost.mpi。 Boost庫似乎工作正常。但是當我嘗試用下面的命令運行下面的代碼時,我得到了錯誤。Boost.MPI問題

測試代碼:

#include <boost/mpi/environment.hpp> 
#include <boost/mpi/communicator.hpp> 
#include <iostream> 
namespace mpi = boost::mpi; 

int main(int argc, char* argv[]) 
{ 
    mpi::environment env(argc, argv); 
    mpi::communicator world; 
    std::cout << "I am process " << world.rank() << " of " << world.size() 
     << "." << std::endl; 
    return 0; 
} 

生成命令:

mpiCC -I/home1/username/boost/include 
-I/usr/mpi/gcc/openmpi-1.2.8/include/ 
-L/home1/username/boost/lib 
-L/usr/mpi/gcc/openmpi-1.2.8/lib64/openmpi 
-lboost_mpi-gcc-mt-1_35 testboostmpi2.cpp 

我得到了以下錯誤尖叫:

testboostmpi2.o: In function `main': 
testboostmpi2.cpp:(.text+0x59): undefined reference to  
`boost::mpi::environment::environment(int&, char**&, bool)' 
testboostmpi2.cpp:(.text+0x63): undefined reference to 
`boost::mpi::communicator::communicator()' 
testboostmpi2.cpp:(.text+0x86): undefined reference to 
`boost::mpi::environment::~environment()' 
testboostmpi2.cpp:(.text+0xb9): undefined reference to 
`boost::mpi::environment::~environment()' 

我會很感激,如果有的話,你可以幫幫我。

回答

2

不幸的是,我使用boost 1.41,所以不可能進行精確比較。但是,當我沒有包含-lboost_mpi(新的庫命名約定)時,我得到了完全相同的錯誤。所以,我會檢查你的目錄是否正確,幷包含你認爲應該包含的內容。

3

假設您使用的是g ++,您可以嘗試使用-Wl,--rpath鏈接器選項。

mpiCC testboostmpi2.cpp -I/home1/username/boost/include-I/usr/mpi/gcc/openmpi-1.2.8/include/ \ 
    -L/home1/username/boost/lib -L/usr/mpi/gcc/openmpi-1.2.8/lib64/openmpi \ 
    -lboost_mpi-gcc-mt-1_35 -Wl,-rpath -Wl,/home1/username/boost/lib \ 
    -Wl,-rpath -Wl,/usr/mpi/gcc/openmpi-1.2.8/lib64/openmpi 

此外,要以正確的順序鏈接,您需要將源文件作爲第一個參數,而不是最後一個。

+1

**「正確的順序,你需要把源文件作爲第一個參數,而不是最後一個。」** +1,因爲這個細節只花了很多小時來安裝和重新安裝boost –