c++ - Unable to compile simple Boost MPI example -


i trying use mpi c++ boost using following code:

#include <boost/mpi/environment.hpp> #include <boost/mpi/communicator.hpp> #include <iostream> namespace mpi = boost::mpi;  int main() {   mpi::environment env;   mpi::communicator world;   std::cout << "i process " << world.rank() << "on " << world.size() << "." << std::endl;   return 0; } 

and have boost mpi compiled , installed:

 ~ ls /usr/local/include/boost | grep mpi mpi mpi.hpp ~ ls /usr/local/lib | grep mpi    libboost_mpi.a libboost_mpi.so libboost_mpi.so.1.62.0   ~ ls /usr/local/lib | grep serialization                                                                                  libboost_serialization.a libboost_serialization.so libboost_serialization.so.1.62.0 libboost_wserialization.a libboost_wserialization.so libboost_wserialization.so.1.62.0 

compiling using

mpic++ -l/usr/local/lib -i/usr/local/include/boost/mpi -lboost_mpi-gcc-mt-1_35 -lboost_serialization mpiboostbindingexample.cpp -o mpiboostbindingexample 

but still got errors saying:

/tmp/cckvwnkr.o: in function `main': mpiboostbindingexample.cpp:(.text+0x27): undefined reference `boost::mpi::environment::environment(bool)' mpiboostbindingexample.cpp:(.text+0x33): undefined reference `boost::mpi::communicator::communicator()' mpiboostbindingexample.cpp:(.text+0x3f): undefined reference `boost::mpi::communicator::size() const' mpiboostbindingexample.cpp:(.text+0x4d): undefined reference `boost::mpi::communicator::rank() const' mpiboostbindingexample.cpp:(.text+0xb8): undefined reference `boost::mpi::environment::~environment()' mpiboostbindingexample.cpp:(.text+0xeb): undefined reference `boost::mpi::environment::~environment()' collect2: error: ld returned 1 exit status 

any help?

works me (ubuntu 16.04) if add -lboost_mpi.

your code (modulo minor edits):

edd@max:/tmp$ cat boostmpi.cpp  #include <boost/mpi/environment.hpp> #include <boost/mpi/communicator.hpp> #include <iostream> namespace mpi = boost::mpi;  int main() {   mpi::environment env;   mpi::communicator world;   std::cout << "i process " << world.rank()              << " on " << world.size() << "." << std::endl;   return 0; } edd@max:/tmp$  

and compile aforementioned library (which mpic++ not know default)

edd@max:/tmp$ mpic++ -o boostmpi boostmpi.cpp -lboost_mpi edd@max:/tmp$ orterun ./boostmpi process 2 on 4. process 3 on 4. process 0 on 4. process 1 on 4. edd@max:/tmp$  

this helped fact boost headers , other libraries have 'system' status, ie accessible additional -i or -l flags.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -