I keep encountering this link error when compiling my application:
error LNK2001: unresolved external symbol "public: __cdecl MPI::Comm::Comm(void)" (??0Comm@MPI@@QEAA@XZ) E:\Users\UT1JVT\Tanoshii\Eden\Inceptor2\Inceptor2\Node.obj Inceptor2
If I compile it twice in a row, it changes to this (probably bec of incremental linking?):
error LNK2019: unresolved external symbol "public: __cdecl MPI::Comm::Comm(void)" (??0Comm@MPI@@QEAA@XZ) referenced in function "public: __cdecl MPI::Intracomm::Intracomm(struct ompi_communicator_t *)" (??0Intracomm@MPI@@QEAA@PEAUompi_communicator_t@@@Z) E:\Users\UT1JVT\Tanoshii\Eden\Inceptor2\Inceptor2\Node.obj Inceptor2
I have tried this in both x64 and 32bit mode with the matching MPI libraries to no avail. I have also defined: OMPI_IMPORTS, OPAL_IMPORTS and ORTE_IMPORTS (which fixed some of my previous link errors) but I still can't get rid of this one.
The offending line is:
_roleLocalComm = &MPI::COMM_WORLD.Split(_roleId,_nodeId);
If I remove this line (all code that creates comm groups), the error goes away. I have built the same source in Linux (Open MPI v1.6.5) and it works fine.
Here's the compile command:
/Zi /nologo /W3 /WX- /Od /D "_DEBUG" /D "_CONSOLE" /D "OMPI_IMPORTS" /D "OPAL_IMPORTS" /D "ORTE_IMPORTS" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fp"x64\Debug\testx64.pch" /Fa"x64\Debug\" /Fo"x64\Debug\" /Fd"x64\Debug\vc100.pdb" /Gd /errorReport:queue
Update: I tried stripping it down to bare bones and using mpic++ to compile it but I still get the same exact problem. Here's the command line:
mpic++ EntryPoint.cpp -showme
cl.exe EntryPoint.cpp /D "OMPI_IMPORTS" /I"C:\Program Files\OpenMPI_v1.6.2-x64\include" /TP /EHsc /link /LIBPATH:"C:\Program Files\OpenMPI_v1.6.2-x64\lib" libmpi_cxx.lib libmpi.lib libopen-pal.lib libopen-rte.lib advapi32.lib Ws2_32.lib shlwapi.lib
couldn't get it to work at first (tons of link errors) but then I realized that OMPI_IMPORTS is not defined so I edited %openmpi%/share/openmpi/mpic++-wrapper-data.txt to add /D "OMPI_IMPORTS"
Also, it might both mentioning that I was also getting a Link failure for MPI::Datatype::Free() which seems to be a known issue. I made a workaround for this by adding the following code. I imagine it won't cause me much of a problem since my datatypes won't be cleaned up until the job completes.
void MPI::Datatype::Free(void) {
}