0
votes

I configured and generated the nmake build files using CMake (2.8.11.2) on Windows 7 64bit for the openmpi 1.4.3 package. I am using the "VS2012 x64 Cross Tools Command Prompt". Unfortunately the link step for the first DLL target fails because some traget libraries are added to the link command line with an '/l' prefix, that causes the linker to issue warnings, but results then in unresolved external symbols, because the needed libraries have been ignored. I.e.

Linking C shared library ..\liblibopen-pal.dll
    cd C:\home\re04179\thirdparty\openmpi-1.4.3-build\vc11\x64\release\opal
    "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -E vs_link_dll C:\PROGRA~2\MICROS~1.0\VC\bin\X86_AM~1\link.exe /nologo @CMakeFiles\libopen-pal.dir\objects1.rsp @C:\Users\RE04179\AppData\Local\Temp\nm1B31.tmp
Visual Studio Non-Incremental Link
LINK:
C:\PROGRA~2\MICROS~1.0\VC\bin\X86_AM~1\link.exe /nologo @CMakeFiles\libopen-pal.dir\objects1.rsp /out:..\liblibopen-pal.dll /implib:..\liblibopen-pal.dll.a /pdb:C:\home\re04179\thirdparty\openmpi-1.4.3-build\vc11\x64\release\liblibopen-pal.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO -lWs2_32.lib -lshlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST 
LINK : warning LNK4044: unrecognized option '/lWs2_32.lib'; ignored

LINK : warning LNK4044: unrecognized option '/lshlwapi.lib'; ignored

   Creating library ..\liblibopen-pal.dll.a and object ..\liblibopen-pal.dll.exp

win32.obj : error LNK2019: unresolved external symbol __imp_WSAGetLastError referenced in function win32_insert

evutil.obj : error LNK2001: unresolved external symbol __imp_WSAGetLastError

if.obj : error LNK2001: unresolved external symbol __imp_WSAGetLastError

win32.obj : error LNK2019: unresolved external symbol __imp_WSACloseEvent referenced in function win32_del

win32.obj : error LNK2019: unresolved external symbol __imp_WSACreateEvent referenced in function win32_recompute_event

win32.obj : error LNK2019: unresolved external symbol __imp_WSAEnumNetworkEvents referenced in function win32_socket_event_callback

win32.obj : error LNK2019: unresolved external symbol __imp_WSAEventSelect referenced in function win32_del

win32.obj : error LNK2019: unresolved external symbol __imp_WSAHtonl referenced in function win32_insert

etc.

By editing line 156 of file 'C:\Program Files (x86)\CMake 2.8\share\cmake-2.8\Modules\Platform\Windows-MSVC.cmake' from

set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib")

to

set(CMAKE_C_STANDARD_LIBRARIES_INIT "ws2_32.lib shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib")

i.e., adding the required libraries explicitly, allows me to build the package successfully, the linker warnings remain, though, and this is certainly only a work-around, but no satisfactory solution to the problem.

1

1 Answers

0
votes

You should add libraries to openmpi cmake file and not change CMake files. And you should never change CMake distribution files but rather fix files which accompany a library you are trying to build. Most of the time it is a library's bug not CMake's.