【问题标题】:(Error) Undefined reference to MPI on Dev C++(错误)在 Dev C++ 上未定义对 MPI 的引用
【发布时间】:2017-08-07 08:09:29
【问题描述】:

我有一个使用 MPI 制作简单程序的任务。在我使用 mpi.h 标头在 Dev C++ 中尝试 Hello World 程序并编译它后,makefile.win 出现并且出现以下错误

D:\Assignment\Project\MPI\tesmpi.o tesmpi.cpp:(.text+0x21): undefined reference to `MPI_Init'
D:\Assignment\Project\MPI\tesmpi.o  tesmpi.cpp (.text$_ZN3MPI9IntracommC2Ev[__ZN3MPI9IntracommC2Ev]+0xf): undefined reference to `MPI::Comm::Comm()'
... and other 190 errors like that
D:\Assignment\Project\MPI\[Error] id returned 1 exit status
D:\Assignment\Project\MPI\recipe for target 'Project' failed

我已经在项目选项中输入了库和包含目录以及带有 msmpi.lib 的链接器。嗯,顺便说一下,我使用 Microsoft MPI 和 Microsoft SDK 作为 MPI。有什么我可以做的吗?

这是我的程序

#include <mpi.h>
#include <stdio.h>

int main(int argc, char** argv) {
    // Initialize the MPI environment
    MPI_Init(NULL, NULL);

    // Get the number of processes
    int world_size;
    MPI_Comm_size(MPI_COMM_WORLD, &world_size);

    // Get the rank of the process
    int world_rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

    // Get the name of the processor
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    int name_len;
    MPI_Get_processor_name(processor_name, &name_len);

    // Print off a hello world message
    printf("Hello world from processor %s, rank %d" " out of %d processors\n",
       processor_name, world_rank, world_size);

    // Finalize the MPI environment.
    MPI_Finalize();

}

【问题讨论】:

    标签: c++ mpi dev-c++ ms-mpi


    【解决方案1】:

    你是如何编译你的程序的?您需要使用mpic++ 命令,而不是普通的 C++ 编译器来执行此操作。

    【讨论】:

    • 我像往常一样使用 dev C++ 编译器编译程序,如何在 dev C++ 编译器上添加mpic++?或者它可以用 cmd 完成?
    【解决方案2】:

    您当前的问题意味着您没有通知 Dev C++ 链接器您要使用 MPI 库。

    在配置中应该有一个地方说明您打算使用哪些库。

    【讨论】:

    • 那么,它在哪里?
    猜你喜欢
    • 2021-06-15
    • 2013-12-25
    • 1970-01-01
    • 1970-01-01
    • 2010-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多