3

我正在尝试在 xcode 4 中运行一些 MPI 程序。我通过键入从 MacPort 安装了 openmpi,sudo port install openmpi并且安装正常完成。然后我将 opt/local/include/openmpi 添加到我的用户标题搜索路径中,将“libmpi.dylib”和“libmpi_cxx.dylib”拖到我的项目中。

但是当我尝试运行该程序时,我收到以下错误消息:

Undefined symbols for architecture x86_64:
  "_MPI_Comm_accept", referenced from:
      MPI::Intracomm::Accept(char const*, MPI::Info const&, int) const in main.o
  "_MPI_Comm_connect", referenced from:
      MPI::Intracomm::Connect(char const*, MPI::Info const&, int) const in main.o
  "_MPI_Comm_disconnect", referenced from:
      MPI::Comm::Disconnect() in main.o
  "_MPI_Comm_get_errhandler", referenced from:
      MPI::Comm::Get_errhandler() const in main.o
  "_MPI_Comm_set_errhandler", referenced from:
      MPI::Comm::Set_errhandler(MPI::Errhandler const&) const in main.o
  "_MPI_Comm_spawn", referenced from:
      MPI::Intracomm::Spawn(char const*, char const**, int, MPI::Info const&, int) const in main.o
      MPI::Intracomm::Spawn(char const*, char const**, int, MPI::Info const&, int, int*) const in main.o
  "_MPI_Comm_spawn_multiple", referenced from:
      MPI::Intracomm::Spawn_multiple(int, char const**, char const***, int const*, MPI::Info const*, int) in main.o
      MPI::Intracomm::Spawn_multiple(int, char const**, char const***, int const*, MPI::Info const*, int, int*) in main.o
  "_MPI_Grequest_complete", referenced from:
      MPI::Grequest::Complete() in main.o
  "_MPI_Op_commutative", referenced from:
      MPI::Op::Is_commutative() const in main.o
  "_MPI_Reduce_local", referenced from:
      MPI::Op::Reduce_local(void const*, void*, int, MPI::Datatype const&) const in main.o
  "_MPI_Win_call_errhandler", referenced from:
      MPI::Win::Call_errhandler(int) const in main.o
  "_MPI_Win_get_errhandler", referenced from:
      MPI::Win::Get_errhandler() const in main.o
  "_MPI_Win_set_errhandler", referenced from:
      MPI::Win::Set_errhandler(MPI::Errhandler const&) const in main.o
  "_ompi_mpi_comm_null", referenced from:
      MPI::Intracomm::Intracomm(ompi_communicator_t*) in main.o
      MPI::Graphcomm::Graphcomm(ompi_communicator_t* const&) in main.o
      MPI::Cartcomm::Cartcomm(ompi_communicator_t* const&) in main.o
  "_ompi_mpi_comm_world", referenced from:
      _main in main.o
  "_ompi_mpi_double", referenced from:
      _main in main.o
  "_ompi_mpi_op_sum", referenced from:
      _main in main.o
  "_ompi_op_set_cxx_callback", referenced from:
      MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我在上述安装过程中遗漏了什么吗?

4

3 回答 3

18
于 2015-07-20T20:40:06.893 回答
5

我遇到了同样的问题,当我从源代码编译 openmpi 时,添加了头文件和库搜索路径,但忘记将库作为链接器标志添加到构建设置中。添加它们解决了这个问题。您可以键入mpicc –showme以查看 mpi 运行所需的库。

于 2012-10-13T22:58:22.410 回答
0

或者只需键入 mpic++ 而不是 mpicc。这对我有用;)

于 2014-05-22T17:48:01.880 回答