0

I am trying to use mpich2 in visual studio 2012.

I found and followed a tutorial.

However I am getting following errors:

1>HelloWorld.obj : error LNK2019: unresolved external symbol _MPI_Init referenced in function _main
1>HelloWorld.obj : error LNK2019: unresolved external symbol _MPI_Finalize referenced in function _main
1>D:\C Projects\HelloWorldMPI\Debug\HelloWorldMPI.exe : fatal error LNK1120: 2 unresolved externals

My code is basic hello world code.

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

main(int argc, char **argv)
{
   int node;
   //
   MPI_Init(&argc,&argv);
   //MPI_Comm_rank(MPI_COMM_WORLD, &node);
   //  
   //printf("Hello World from Node %d\n",node);
   //         
   MPI_Finalize();
}

By the way I can see mpi.h header with rigth clicking and clicking to open document. So program can find mpi.h header.

Edit:

The the way I linked library.

Solution Exp -> VC++ Directories ->Include Directories -> C:\Program Files\MPICH2\include;$(IncludePath)

Solution Exp -> VC++ Directories ->Library Directories -> C:\Program C:\Program Files\MPICH2\lib;$(LibraryPath)

Solution Exp -> Linker -> General -> Additional Library Directories -> C:\Program Files\MPICH2\lib;%(AdditionalLibraryDirectories)

Solution Exp -> Linker -> Input -> AdditionalDipendencies -> cxx.lib;mpi.lib;%(AdditionalDependencies)

Umur Gurelli
  • 83
  • 2
  • 9
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – too honest for this site Nov 07 '16 at 07:23
  • The header is not the library! – too honest for this site Nov 07 '16 at 07:23
  • Did you point 22 of the [tutorial](http://nick-goodman.blogspot.ch/2012/02/using-mpich-from-ms-visual-studio-2010.html) ? [This link](https://blogs.technet.microsoft.com/windowshpc/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program/) may help too. – Jabberwocky Nov 07 '16 at 07:32
  • I edited question with describing what I have done. – Umur Gurelli Nov 07 '16 at 07:38
  • The missing symbols are undecorated, which hints to the project being 64-bit. Make sure you are not trying to link against a 32-bit version of MPICH. – Hristo Iliev Nov 08 '16 at 12:21

0 Answers0