0
부스트 mpi를 사용하여 더 복잡한 데이터 유형을 전달하려고합니다. http://theboostcpplibraries.com/boost.mpi-simple-data-exchangeboost_mpi로 문자열 유형을 보내는 방법은 무엇입니까?
먼저이 튜토리얼의 예제 47.5에서 작동하는 char 배열로 문자열을 보내려고합니다. 코드는 다음과 같습니다
이#include <boost/mpi.hpp>
#include <iostream>
int main(int argc, char *argv[])
{
boost::mpi::environment env{argc, argv};
boost::mpi::communicator world;
if (world.rank() == 0)
{
char buffer[14];
world.recv(boost::mpi::any_source, 16, buffer, 13);
buffer[13] = '\0';
std::cout << buffer << '\n';
}
else
{
const char *c = "Hello, world!";
world.send(0, 16, c, 13);
}
}
내가 컴파일하고 다음 명령을 잘 실행 수 : 다음
mpic++ -std=c++0x 3.cpp -o 3 -lboost_mpi
mpiexec -np 3 ./3
, 내가 (같은 튜토리얼 예 47.5에서) 문자열 유형을 변경하려고 :
> /usr/bin/ld: /tmp/ccRNu1AY.o: undefined reference to symbol '_ZTIN5boost7archive6detail14basic_iarchiveE'
> //usr/lib/x86_64-linux-gnu/libboost_serialization.so.1.54.0: error adding symbols: DSO missing from command line
> collect2: error: ld returned 1 exit status
:
#include <boost/mpi.hpp>
#include <boost/serialization/string.hpp>
#include <string>
#include <iostream>
int main(int argc, char *argv[])
{
boost::mpi::environment env{argc, argv};
boost::mpi::communicator world;
if (world.rank() == 0)
{
std::string s;
world.recv(boost::mpi::any_source, 16, s);
std::cout << s << '\n';
}
else
{
std::string s = "Hello, world!";
world.send(0, 16, s);
}
}
내가 컴파일하고이 코드를 연결 , 나는 다음과 같은 오류가 발생했습니다
모든 도움을 주시면 대단히 감사하겠습니다.
는 일이! 고맙습니다. 다른 mpi 기능과 유사한 문제가 발생할 경우를 대비하여 향후 어떻게 라이브러리를 추가 할 수 있습니까? – Mehrdad