[mpich-discuss] Linking to cxx.lib with MinGW 4.6.1

Alexey Izbyshev izbyshev at gmail.com
Wed Dec 28 07:00:28 CST 2011


Hello,

I'm trying to build a simplest MPICH2 C++ code with MinGW 4.6.1 on Windows
7 32-bit but getting linker errors:

test.cpp:

#include "mpi.h"

int main(int argc, char **argv) {
  MPI::Init(argc, argv);
  MPI::Finalize();
  return 0;
}

D:\ASTU\Multithreading\Lab08\MPICH2>g++ -Iinclude -Llib test.cpp -lcxx -lmpi
C:\Users\izbyshev\AppData\Local\Temp\ccaG6E2p.o:test.cpp:(.text+0x1c):
undefined reference to `MPI::Init(i
nt&, char**&)'
C:\Users\izbyshev\AppData\Local\Temp\ccaG6E2p.o:test.cpp:(.text+0x21):
undefined reference to `MPI::Finali
ze()'
collect2: ld returned 1 exit status

I have no problems with C version of this code (linking to mpi.lib only).
Visual Studio successfully builds both C and C++ versions.
I wonder is it possible that MinGW is somehow incompatible with cxx.lib?

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.
So for me the only option is to link to *.lib if I don't want to downgrade
MinGW or use VS.

Don't know if it hepls, but VS shows these warnings when linking:

1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other
libs; use /NODEFAULTLIB:library
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20111228/29bdf665/attachment.htm>


More information about the mpich-discuss mailing list