After the MPI is configured in vs2017, there is a problem with the operation
Already configured in vs2017
VC ++ directory-> include directory, add: C: \ Program Files \ MPICH2 \ include
VC ++ directory-> library directory, add: C: \ Program Files \ MPICH2 \ lib
C / C ++-> preprocessor-> preprocessor definition , Add: MPICH_SKIP_MPICXX
C / C ++-> code generation-> runtime library, select: multi-threaded debugging (/ MTd); linker-
> input-> additional dependencies, add: "mpi.lib;"
helloword program code
int main(int argc, char *argv[])
// int argc;
// char *argv[];
{
int myid, numprocs, namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv); /* starts MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* get current process id */
MPI_Comm_size(MPI_COMM_WORLD, &numprocs); /* get number of processes */
MPI_Get_processor_name(processor_name, &namelen);
if (myid == 0) printf("number of processes: %d\n", numprocs);
printf("%s: Hello world from process %d \n", processor_name, myid);
MPI_Finalize();
return 0;
//system("pause");
}
Error in execution
Solution:
Project properties-> upper right corner-> configuration manager-> active solution platform, select: x64;
After changing, pay attention to re-configure according to the above steps