Hello,<br><br>I'm trying to build a simplest MPICH2 C++ code with MinGW 4.6.1 on Windows 7 32-bit but getting linker errors:<br><br>test.cpp:<br><br>#include "mpi.h"<br><br>int main(int argc, char **argv) {<br>
MPI::Init(argc, argv);<br> MPI::Finalize();<br> return 0;<br>}<br><br>D:\ASTU\Multithreading\Lab08\MPICH2>g++ -Iinclude -Llib test.cpp -lcxx -lmpi<br>C:\Users\izbyshev\AppData\Local\Temp\ccaG6E2p.o:test.cpp:(.text+0x1c): undefined reference to `MPI::Init(i<br>
nt&, char**&)'<br>C:\Users\izbyshev\AppData\Local\Temp\ccaG6E2p.o:test.cpp:(.text+0x21): undefined reference to `MPI::Finali<br>ze()'<br>collect2: ld returned 1 exit status<br><br>I have no problems with C version of this code (linking to mpi.lib only). Visual Studio successfully builds both C and C++ versions.<br>
I wonder is it possible that MinGW is somehow incompatible with cxx.lib?<br><br>I also tried to link to lib*.a but got unresolved references to SjLj-related functions. I found out that it is due an old version of MinGW used to build those lib*.a. <br>
So for me the only option is to link to *.lib if I don't want to downgrade MinGW or use VS.<br><br>Don't know if it hepls, but VS shows these warnings when linking:<br><br>1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library<br>
1>cxx.lib(initcxx1.obj) : warning LNK4099: PDB 'vc80.pdb' was not found with 'cxx.lib(initcxx1.obj)' or at 'D:\Trash\MPI\test\Debug\vc80.pdb'; linking object as if no debug info<br>