none
how to solve this problem,Could every body please give me any suggestion? RRS feed

  • Question

  • 1>------ Build started: Project: MPI001, Configuration: Debug Win32 ------
    1>  main.cpp
    1>main.obj : error LNK2019: unresolved external symbol _MPI_Comm_size@8 referenced in function "int __cdecl _tmain(int,char * * const)" (?_tmain@@YAHHQAPAD@Z)
    1>main.obj : error LNK2019: unresolved external symbol _MPI_Comm_rank@8 referenced in function "int __cdecl _tmain(int,char * * const)" (?_tmain@@YAHHQAPAD@Z)
    1>main.obj : error LNK2019: unresolved external symbol _MPI_Get_processor_name@8 referenced in function "int __cdecl _tmain(int,char * * const)" (?_tmain@@YAHHQAPAD@Z)
    1>main.obj : error LNK2019: unresolved external symbol _MPI_Init@8 referenced in function "int __cdecl _tmain(int,char * * const)" (?_tmain@@YAHHQAPAD@Z)
    1>main.obj : error LNK2019: unresolved external symbol _MPI_Finalize@0 referenced in function "int __cdecl _tmain(int,char * * const)" (?_tmain@@YAHHQAPAD@Z)
    1>LIBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced 

    #include "mpi.h"
    #include <stdio.h>
    #include <math.h>
    #pragma comment (lib, "msmpi.lib")
    
    int _tmain(int argc, char* argv[])
    {
    	int myid, numprocs;
    	int namelen;
    
    	char processor_name[MPI_MAX_PROCESSOR_NAME];
    
    	MPI_Init(&argc, &argv);
    	MPI_Comm_rank(MPI_COMM_WORLD, &myid);
    	MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
    	MPI_Get_processor_name(processor_name, &namelen);
    
    	fprintf(stderr, "Hello World! Process %d of %d on %s\n", myid, numprocs, processor_name);
    
    	MPI_Finalize();
    	return 0;
    }

    Wednesday, December 2, 2015 6:22 AM

All replies

  • Hi there,

    It's likely that you either did not include msmpi.lib in the list of additional libraries or that you included the x64 version of msmpi.lib and are trying to build a 32-bit application. The following link will have some screenshots that will help you include the right msmpi.lib

    http://blogs.technet.com/b/windowshpc/archive/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program.aspx

    Let us know if you still have issues with building the program.

    Anh

    Wednesday, December 2, 2015 7:26 AM