2017-03-16 375 views
0

我有一个使用MPI进行简单程序的任务。我尝试在开发的C++一个Hello World程序后使用mpi.h头和编译,该makefile.win正在出现,并以下错误即将(错误)在Dev C++上未定义对MPI的引用

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。呃,顺便说一句,我使用微软MPI和微软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(); 

}

回答

0

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

+0

我像往常一样使用dev C++编译器编译程序,如何在dev C++编译器中添加'mpiC++'?或者它可以用cmd完成? – newcomers

0

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

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

+0

那么,它在哪里? – newcomers