views:

199

answers:

2

Hello all,

I'm working on an HPC. And on that HPC an old version of Boost was installed and that boost library doesn't have Boost.MPI. I requested from Admins to install it on the HPC. But they requested from me to install it on my home directory. So i installed both boost and boost.mpi on my home directory. Boost library seems to work correctly. But when I try to run the following code with the command below I got errors.

Test code:

#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;
}

Build command:

 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

I got the following errors screaming:

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()'

I'd be very grateful, if any of you can help.

A: 

Unfortunately, I'm using boost 1.41, so an exact comparison is impossible. However, I got the exact same errors when I did not include -lboost_mpi (the new library naming convention). So, I'd check that your directories are correct and contain what you think they should contain.

rcollyer
A: 

Assuming you are using g++ you can try using the -Wl,--rpath linker option.

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

Also to link in the correct order you need to put the source file as the first argument, not the last.

baol