2017-03-16 369 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