2

I have installed MPICH2 .. and I'm able to execute the sample code cpi.exe using mpiexec .. but when I open the sample code using visual studio and tried to rebuild it .. it gave me linker errors.. As per mpich2-1.4.1p1/doc/userguide/user.pdf on http://fossies.org/unix/misc/mpich2-1.4.1p1.tar.gz/

guidlines for running
MPICH2 under windows... 
MS visual studio..

I have created console win 32 project and was able to do these steps

{
For MS Developer Studio users: Create a project and add
C:\Program Files\MPICH2\include
to the include path and
C:\Program Files\MPICH2\lib
to the library path. Add mpi.lib and cxx.lib to the link command.
}

but couldn't do

{
Add
cxxd.lib to the Debug target link instead of cxx.lib.
}

as I don't know .. where is Debug target link set in visual studio...

When I tried building project it gave 8 linker errors

{
1>IS-MPI.obj : error LNK2019: unresolved external symbol _MPI_Finalize referenced in function _main
1>IS-MPI.obj : error LNK2019: unresolved external symbol _MPI_Reduce referenced in function _main
1>IS-MPI.obj : error LNK2019: unresolved external symbol _MPI_Bcast referenced in function _main
1>IS-MPI.obj : error LNK2019: unresolved external symbol _MPI_Wtime referenced in function _main
1>IS-MPI.obj : error LNK2019: unresolved external symbol _MPI_Get_processor_name referenced in function _main
1>IS-MPI.obj : error LNK2019: unresolved external symbol _MPI_Comm_rank referenced in function _main
1>IS-MPI.obj : error LNK2019: unresolved external symbol _MPI_Comm_size referenced in function _main
1>IS-MPI.obj : error LNK2019: unresolved external symbol _MPI_Init referenced in function _main
1>C:\Users\Sheetal Tare\Documents\Visual Studio 2010\Projects\IS-MPI\Debug\IS-MPI.exe : fatal error LNK1120: 8 unresolved externals
}

Please help me out .. how to resolve these ??

Grizzly
  • 19,595
  • 4
  • 60
  • 78
star
  • 59
  • 1
  • 7

3 Answers3

2

As you probably have already done add the

  1. MPI\lib to the "Additional Library Directories"

  2. the impimt.lib and impicxx.lib to the "Additional Dependencies"

  3. Additional Include Directories to "\MPI\win_32\blahblah\include"

  4. #include "mpi.h" to your source files where you are using the mpi apis

Jay D
  • 3,263
  • 4
  • 32
  • 48
  • Do you need any further help for this question ? if not could you accept the answer. Thanks-Jay. – Jay D Jan 15 '12 at 21:42
1

Resurrecting old question, but I had the same problem just recently. Make sure that any paths added to Linker or C/C++ Visual Studio settings are added in quotes.

So your additional library dependencies or include folders should have: "C:\Program Files\Any_MPI_Implementation\lib" instead of just C:\Program Files\Any_MPI_Implementation\lib

LordTwaroog
  • 1,738
  • 12
  • 23
0

It is better to use MS-MPI (based on MPICH2) with Visual Studio for debugging:

https://stackoverflow.com/a/15513214/1214984

Community
  • 1
  • 1
Jichao
  • 1,753
  • 1
  • 14
  • 11