<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I am trying to compile a simple c++ MPI program using Visual Studio
2008 (professional) and MPICH2 on Windows 7 professional.<br>
<br>
I downloaded and ran the x86_64 (version 1.4.1p1) msi file from the
MPICH2 website.<br>
<br>
I have set C:\Program Files\MPICH2\bin as a Path variable.<br>
<br>
I have tried two different ways to set the include and lib
directories in my Visual Studio MPI project. The first is to set
both of them under Tools->Options->Projects and
Solutions->VC++ Directories.<br>
<br>
My program is very simple as I am just trying to get MPI to work on
Windows for the first time.<br>
<hr size="2" width="100%">#include <mpi.h><br>
#include <cstdio><br>
<br>
int main(int argc, char *argv[])<br>
{<br>
int pid; <br>
int numpid; <br>
<br>
MPI_Init(&argc,&argv);<br>
<br>
MPI_Comm_size(MPI_COMM_WORLD,&numpid); <br>
//get the rank of the current process and store it in the pid
variable<br>
MPI_Comm_rank(MPI_COMM_WORLD,&pid); <br>
printf("Hello from processor %d of %d!\n",pid,numpid);<br>
<br>
MPI_Finalize();<br>
<br>
return 0;<br>
}<br>
<hr size="2" width="100%"><br>
I get the following errors when I try to compile it:<br>
1>Compiling...<br>
1>main.cpp<br>
1>Linking...<br>
1>main.obj : error LNK2019: unresolved external symbol
_MPI_Finalize referenced in function _main<br>
1>main.obj : error LNK2019: unresolved external symbol
_MPI_Comm_rank referenced in function _main<br>
1>main.obj : error LNK2019: unresolved external symbol
_MPI_Comm_size referenced in function _main<br>
1>main.obj : error LNK2019: unresolved external symbol _MPI_Init
referenced in function _main<br>
1>Y:\ModelCenter_LinkingCodes\zonair_mpi\Debug\zonair_mpi.exe :
fatal error LNK1120: 4 unresolved externals<br>
<br>
I believe this tells me that it is not linking in the MPI library
files.<br>
<br>
The other way is to go to Project->Properties->Configuration
Properties->C/C++->General->Additional Include Directories.
I then put "C:\Program Files\MPICH2\include" in the box.<br>
<br>
Then I go to Project->Properties->Configuration
Properties->Linker->General->Additional Library
Directories. I then put "C:\Program Files\MPICH2\lib" into the box.<br>
<br>
Finally, I go to Project->Properties->Configuration
Properties->Linker->Input->Additional Dependencies. I then
put mpi.lib into the box.<br>
<br>
Now when I compile I get the exact same error message:<br>
1>Compiling...<br>
1>main.cpp<br>
1>Linking...<br>
1>main.obj : error LNK2019: unresolved external symbol
_MPI_Finalize referenced in function _main<br>
1>main.obj : error LNK2019: unresolved external symbol
_MPI_Comm_rank referenced in function _main<br>
1>main.obj : error LNK2019: unresolved external symbol
_MPI_Comm_size referenced in function _main<br>
1>main.obj : error LNK2019: unresolved external symbol _MPI_Init
referenced in function _main<br>
1>Y:\ModelCenter_LinkingCodes\zonair_mpi\Debug\zonair_mpi.exe :
fatal error LNK1120: 4 unresolved externals<br>
<br>
What am I missing to get it to compile?<br>
<br>
Thanks.
</body>
</html>