CMake / NMake link error on Visual Studio 2012 / vc11 - cmake

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.

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.

Related

Failed linking C shared library mod_md.so when compile HTTPD with static cURL

I'm compiling HTTPD 2.4.54 (and its modules) with static cURL.
These are libraries and tools that I use: httpd-2.4.54, apr-1.7.0, apr-util-1.6.1, pcre-8.45, curl-7.83.1, expat-2.4.8, jansson-2.14, lua-5.4.4, mod_fcgid-2.3.9, openssl-1.1.1o, zlib-1.2.12, libxml2-2.9.14, brotli-1.0.9, nghttp2-1.47.0, Gawk v3.1.6-1, CMake v3.23.1, NASM v2.15.05, Visual Studio 2013 Ultimate.
I compiled it in order: zlib, PCRE, Expat, OpenSSL, libxml2, janssonm, Brotli, Lua, APR, APR-Util, Nghttp2. All have been successfully compiled, no errors occurred.
With the cURL, first, I compiled the dynamic cURL (libcurl_imp.lib file). Here's my compiled command line:
cd /D C:\httpd\srclib\curl\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DCURL_USE_OPENSSL=ON -DCURL_USE_SCHANNEL=ON -DCURL_WINDOWS_SSPI=ON -DCURL_BROTLI=ON -DUSE_NGHTTP2=ON -DHAVE_LDAP_SSL=ON -DENABLE_UNICODE=ON -DCURL_STATIC_CRT=OFF ..
Then I used nmake and nmake install, successful dynamic cURL compiler!
I continued to compile the static cURL (libcurl.lib file) immediately with the following command:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DCURL_USE_OPENSSL=ON -DCURL_USE_SCHANNEL=ON -DCURL_WINDOWS_SSPI=ON -DCURL_BROTLI=ON -DUSE_NGHTTP2=ON -DHAVE_LDAP_SSL=ON -DENABLE_UNICODE=ON -DCURL_STATICLIB=ON -DCURL_STATIC_CRT=OFF -DBUILD_SHARED_LIBS=OFF ..
Then I used nmake and nmake install, the compilation successfully, no errors occur.
After compiling cURL, I moved on to HTTPD compilation, here's my compiled command line:
cd /D C:\httpd\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DENABLE_MODULES=i -DINSTALL_PDB=OFF ..
After running nmake later, I encountered an error:
[ 65%] Linking C shared library mod_md.so
LINK: command "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe /nologo #CMakeFiles\mod_md.dir\objects1.rsp /out:mod_md.so /implib:mod_md.lib /pdb:C:\httpd\bin\mod_md.pdb /dll /version:0.0 /base:#C:/httpd/bin/BaseAddr.ref,mod_md.so /machine:X86 /INCREMENTAL:NO \phpStudy\Apache\lib\libssl.lib \phpStudy\Apache\lib\libcrypto.lib \phpStudy\Apache\lib\libcurl.lib \phpStudy\Apache\lib\jansson.lib mod_watchdog.lib libhttpd.lib \phpStudy\Apache\lib\libapr-1.lib \phpStudy\Apache\lib\libaprutil-1.lib \phpStudy\Apache\lib\apr_ldap-1.lib ws2_32.lib mswsock.lib \phpStudy\Apache\lib\pcre.lib ws2_32.lib mswsock.lib kernel32.libuser32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:mod_md.so.manifest" failed (exit code 1120) with the following output:
Creating library mod_md.lib and object mod_md.exp
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_global_init referenced in function _md_curl_init
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_slist_append referenced in function _curlify_headers
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_slist_free_all referenced in function _md_curl_req_cleanup
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_strerror referenced in function _md_curl_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_initreferenced in function _internals_setup
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function _internals_setup
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _md_curl_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function _md_curl_req_cleanup
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_getinfo referenced in function _md_curl_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_init referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_add_handle referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_remove_handle referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_wait referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_perform referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_cleanup referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_info_read referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_strerror referenced in function _md_curl_multi_perform
mod_md.so : fatal error LNK1120: 17 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
Earlier, I changed a little CMakeLists.txt. Specifically, I have assigned the libcurl.lib file to be a cURL library and print it on the path to the library. I checked and certainly the path was correct.
Then, I checked in the folder C:\phpStudy\Apache\lib both files are libcurl.lib and libcurl_imp.lib are inside.
The above error only occurs when I use the static library file (libcurl.lib file) of cURL. But if I change to a dynamic library file (libcurl_imp.lib file), the compilation will be successful, the compilation process will take place normally.
I tried with adding (and removing) the -DCURL_STATICLIB=ON flag when compiling static cURL. But nothing changed at the linking C shared library mod_md.so step.
What is not right happened to static cURL? Why can't I compile HTTPD with static cURL?

"cannot open file 'user32.lib'" when trying to use Visual Studio 2005 on Windows 10

I'm attempting to match output with a C++ Win32 executable compiled with Visual Studio 2005, so I'm trying to use that MSVC to do so. I have a project defined in CMake. I open "Visual Studio 2005 Command Prompt", but when I try to cmake -G "NMake Makefiles" .. I get LINK : fatal error LNK1104: cannot open file 'user32.lib'.
Here's the CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
# set the project name
project(LEGOStarWarsSaga)
# add the executable
add_executable(LEGOStarWarsSaga src/main.cpp)
Here's the Visual Studio 2005 Command Prompt output:
C:\Users\aprim\Documents\lstsc>mkdir build
C:\Users\aprim\Documents\lstsc>cd build
C:\Users\aprim\Documents\lstsc\build>cmake -G "NMake Makefiles" ..
-- The C compiler identification is MSVC 14.0.50727
-- The CXX compiler identification is MSVC 14.0.50727
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/aprim/Documents/lstsc/build/CMakeFiles/CMakeTmp
Run Build Command(s):nmake /nologo cmTC_41947\fast && "C:\Program Files (x86)\Microsoft Visual Studio 8\VC\BIN\nmake.exe" -f CMakeFiles\cmTC_41947.dir\build.make /nologo -L CMakeFiles\cmTC_41947.dir\build
Building C object CMakeFiles/cmTC_41947.dir/testCCompiler.c.obj
C:\PROGRA~2\MI30EB~1\VC\bin\cl.exe #C:\Users\aprim\AppData\Local\Temp\nmBDB4.tmp
testCCompiler.c
Linking C executable cmTC_41947.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_41947.dir --rc=C:\PROGRA~2\MI30EB~1\VC\bin\rc.exe --mt=C:\PROGRA~2\MI30EB~1\VC\bin\mt.exe --manifests -- C:\PROGRA~2\MI30EB~1\VC\bin\link.exe /nologo #CMakeFiles\cmTC_41947.dir\objects1.rsp #C:\Users\aprim\AppData\Local\Temp\nmBE13.tmp
LINK Pass 1: command "C:\PROGRA~2\MI30EB~1\VC\bin\link.exe /nologo #CMakeFiles\cmTC_41947.dir\objects1.rsp /out:cmTC_41947.exe /implib:cmTC_41947.lib /pdb:C:\Users\aprim\Documents\lstsc\build\CMakeFiles\CMakeTmp\cmTC_41947.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL:YES /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_41947.dir/intermediate.manifest CMakeFiles\cmTC_41947.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'user32.lib'
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 8\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:4 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/aprim/Documents/lstsc/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/aprim/Documents/lstsc/build/CMakeFiles/CMakeError.log".
After reading online, I've come to find that this is something to do with missing the Windows SDK. However, I have the Windows SDKs 7.1 and 10.0 installed. What am I missing?
Bonus points if there's a build tool that'll make this process (nearly) seamless for anyone cloning the project.
EDIT: Installing Visual Studio 2005 Professional with the full Visual C++ option installs the SDK properly, and the project builds. My worry is that not everyone has access to VS 2005 Pro.

CMake building for Windows (clang-cl) using Ninja Generator

I am trying to build a simple application on a Windows machine using CMake as the main build tool. Once CMake is invoked on the project the is an error on configuration phase:
> cmake -H. -G Ninja -Bbuild -DCMAKE_C_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" -DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe"
-- The C compiler identification is Clang 7.0.0
-- The CXX compiler identification is Clang 7.0.0
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe --broken
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/CMakeTestCCompile
r.cmake:52 (message):
The C compiler
"C:/Program Files/LLVM/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/mak/Desktop/cmake-test/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/Qt/Tools/QtCreator/bin/ninja.exe" "cmTC_f5485"
[1/2] Building C object CMakeFiles\cmTC_f5485.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_f5485.exe
FAILED: cmTC_f5485.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_f5485.dir --manifests -- CMAKE_LINKER-NOTFOUND /nologo CMakeFiles\cmTC_f5485.dir\testCCompiler.c.obj /out:cmTC_f5485.exe /implib:cmTC_f5485.lib /pdb:cmTC_f5485.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
RC Pass 1: command "rc /foCMakeFiles\cmTC_f5485.dir/manifest.res CMakeFiles\cmTC_f5485.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the given file
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
I read a lot through the web but my problem was not solved by any proposed solution. What I found so far is a simmilar but maybe outdated solution to the same problem which did not work for me, because Ninja was not able to build the executable:
> ninja all
[1/2] Building CXX object CMakeFiles/minimal.dir/main.cpp.obj
FAILED: CMakeFiles/minimal.dir/main.cpp.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe -MD -MT CMakeFiles/minimal.dir/main.cpp.obj -MF CMakeFiles\minimal.dir\main.cpp.obj.d -o CMakeFiles/minimal.dir/main.cpp.obj -c ../main.cpp
clang-cl.exe: warning: unknown argument ignored in clang-cl: '-MF' [-Wunknown-argument]
clang-cl.exe: error: no such file or directory: 'CMakeFiles/minimal.dir/main.cpp.obj'
clang-cl.exe: error: no such file or directory: 'CMakeFiles\minimal.dir\main.cpp.obj.d'
ninja: build stopped: subcommand failed.
Before this error CMake configured properly except that all compilers ABI info detection failed - but CMake resumed without error. There are some other questions out there which did not help either.
The official documentation states it is quite simple but in fact it is not.
So: How do I build a simple C++ project using CMake with the Ninja generator and Clang as the compiler? I try to avoid the installation of Visual Studio but it would be great if generated binaries are compatible with MSVC build binaries.
Versions:
CMake 3.12.2
Ninja 1.8.2
Clang 7.0.0
Example: Here is the minial example which I am working with:
CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(minimal)
add_executable(${PROJECT_NAME} main.cpp)
main.cpp
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}
To compile with clang-cl, it is necessary to run cmake with MSVC environment loaded (use vcvarsall.bat). Otherwise it tries to use GCC compatibility options.
It is enough to install just the Build Tools.

VS 2017 cmake error

I am trying to build my code using 3d builder. Am using VS 2017 version. Previously it was working fine but after windows update while trying to open code using VS cmake compiler error. Hereby attaching the log files of error. Is anyone facing the same error? Could someone suggest a way to resolve it?
Build started 7/20/2018 6:39:28 PM.
Project "C:\code\dump64\CMakeFiles\3.8.20170425-g0257b-dirty\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc141.pdb" /Gd /TP /FC /errorReport:queue CMakeCXXCompilerId.cpp
CMakeCXXCompilerId.cpp
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X64 Debug\CMakeCXXCompilerId.obj
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\code\dump64\CMakeFiles\3.8.20170425-g0257b-dirty\CompilerIdCXX\CompilerIdCXX.vcxproj]
Done Building Project "C:\code\dump64\CMakeFiles\3.8.20170425-g0257b-dirty\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets) -- FAILED.
Build FAILED.

C compiler identification is unknown despite setting CC and CXX variables

I'm using the command:
cmake CC="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe"
CXX="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe" -G "Visual Studio 12
Win64" -DBOOST_ROOT="c:\local\boost_1_56_0" -DBOOST_LIBRARYDIR="c:\local\boost_1_56_0\lib64-
msvc-12.0" ..
It says:
The C compiler identification is unknown
and
The CXX compiler identification is unknown
How is it possible when I set those variables right there?
EDIT: Error log file:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
Microsoft (R) Build Engine version 12.0.30723.0
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 21-09-2014 20:17:49.
Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\CL.exe /c /nologo /W0 /WX- /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TC /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.
Build FAILED.
"D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.47
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
Microsoft (R) Build Engine version 12.0.30723.0
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 21-09-2014 20:17:50.
Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\CL.exe /c /nologo /W0 /WX- /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /errorReport:queue CMakeCXXCompilerId.cpp
CMakeCXXCompilerId.cpp
Link:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X64 Debug\CMakeCXXCompilerId.obj
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj]
Done Building Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets) -- FAILED.
Build FAILED.
"D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.50
The compiler can be selected by using the CC and CXX variables, but by it's much more complicated than using the -G (generator) parameter. For one, the slashes in the path must be Unix style (/) and they don't take effect after the first time CMake configuration is ran unless the cache is cleared.
For a list of available generator options include the --help option
The paths to the Boost library must also use Unix style slashes (/). Many of the commands will convert Windows paths, but when passing in definitions at the command-line you'll want to always use Unix style paths.
Your command would change to the following:
cmake -G "Visual Studio 12 2013 Win64" -DBOOST_ROOT="C:/local/boost_1_56_0" -DBOOST_LIBRARYDIR="C:/local/boost_1_56_0/lib64-msvc-12.0" ..
You'll also want to make sure that your PATH environment variable is setup correctly for Visual Studio and x64. This can be done easily by opening a VS2013 x64 Native Tools Command Prompt using the command below:
cmd /k "%VS120CoMNTOOLS%\..\..\VC\vcvarsall.bat" amd64
In addition, you should make sure you're clearing out the cmake cache before you try. The easiest way to do this is to delete your cmake build folder, but you can also use the CMake-gui to clear the cache.