CMake - fatal error with visual studio 2008 - c++

I'm receiving a cmake error while configuring with cmake-gui:
The C compiler "C:/Program Files (x86)/Microsoft Visual Studio
9.0/VC/bin/cl.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/admin/Desktop/myproject/CMakeFiles/CMakeTmp
Run Build Command:c:\PROGRA~2\MICROS~1.0\Common7\IDE\devenv.com
CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec
Microsoft (R) Visual Studio Version 9.0.21022.8.
Copyright (C) Microsoft Corp. All rights reserved.
1>------ Build started: Project: cmTryCompileExec, Configuration:
Debug Win32 ------
1>Compiling...
1>Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for
80x86
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>cl /D "CMAKE_INTDIR=\"Debug\"" /D "_MBCS" /FD /MT
/Fo"cmTryCompileExec.dir\Debug\\"
/Fd"C:\Users\admin\Desktop\myproject\CMakeFiles\CMakeTmp\Debug/cmTryCompileExec.pdb"
/c /TC .\testCCompiler.c
1>testCCompiler.c
1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
1>Build log was saved at
"file://C:\Users\admin\Desktop\myproject\CMakeFiles\CMakeTmp\cmTryCompileExec.dir\Debug\BuildLog.htm"
1>cmTryCompileExec - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
why can't cmake let the vs compiler find the libraries it needs?

I had a rc.exe not-found error on my visual studio 2008 installation. Solved it, solved the abovementioned problem.
Sorry for troubling you.

Related

Cmake not able to compile a simple test program in visual studio 19

I cloned a library that i needed to use for a coding task and visual code auto-compiled its cmake automatically giving me this,i've already looked all over stack overflow and seen similar problems with cl.exe but the solutions dont seem to be anything that fits my problem, the error is following:
Severity Code Description Project File Line Suppression State
Error CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.18/Modules/CMakeTestOBJCXXCompiler.cmake:62 (message):
The Objective-C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/puzzlenew/out/build/x64-Debug (default)/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_0f8c7 && [1/2] Building OBJCXX object CMakeFiles\cmTC_0f8c7.dir\testOBJCXXCompiler.mm.o
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29337 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9002 : ignoring unknown option '-x'
cl : Command line warning D9024 : unrecognized source file type 'objective-c++', object file assumed
cl : Command line warning D9027 : source file 'objective-c++' ignored
cl : Command line warning D9024 : unrecognized source file type 'testOBJCXXCompiler.mm', object file assumed
cl : Command line warning D9027 : source file 'testOBJCXXCompiler.mm' ignored
cl : Command line warning D9021 : no action performed
[2/2] Linking OBJCXX executable cmTC_0f8c7.exe
FAILED: cmTC_0f8c7.exe
cmd.exe /C "cd . && C:\PROGRA~2\MIB055~1\2019\COMMUN~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe /machine:x64 CMakeFiles\cmTC_0f8c7.dir\testOBJCXXCompiler.mm.o -o cmTC_0f8c7.exe && cmd.exe /C "cd /D "D:\puzzlenew\out\build\x64-Debug (default)\CMakeFiles\CMakeTmp" && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file C:/src/win32/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary "D:/puzzlenew/out/build/x64-Debug (default)/CMakeFiles/CMakeTmp/cmTC_0f8c7.exe" -installedDir C:/src/win32/vcpkg/installed/x64-windows/bin -OutVariable out""
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29337 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9002 : ignoring unknown option '/machine:x64'
cl : Command line warning D9024 : unrecognized source file type 'CMakeFiles\cmTC_0f8c7.dir\testOBJCXXCompiler.mm.o', object file assumed
Microsoft (R) Incremental Linker Version 14.28.29337.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:testOBJCXXCompiler.mm.exe
/out:cmTC_0f8c7.exe
CMakeFiles\cmTC_0f8c7.dir\testOBJCXXCompiler.mm.o
LINK : fatal error LNK1181: cannot open input file 'CMakeFiles\cmTC_0f8c7.dir\testOBJCXXCompiler.mm.o'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project. C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.18/Modules/CMakeTestOBJCXXCompiler.cmake 62

NMAKE : fatal error U1077: return code '0x2'

I am trying to build libsvm binary for Windows. But nmake returns an error code.
C:\Users\user\Desktop\libsvm-3.23>nmake -f Makefile.win clean all
Microsoft (R) Program Maintenance Utility Version 14.14.26433.0
Copyright (C) Microsoft Corporation. All rights reserved.
erase /Q *.obj windows\*.exe windows\*.dll windows\*.exp windows\*.lib
Could Not Find C:\Users\user\Desktop\libsvm-3.23\*.obj
Could Not Find C:\Users\user\Desktop\libsvm-3.23\windows\*.exe
cl.exe /nologo /O2 /EHsc /I. /D _WIN64 /D _CRT_SECURE_NO_DEPRECATE -c sv
m.cpp
svm.cpp
C:\Program Files (x86)\Microsoft VisualStudio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\include\vcruntime.h(180): error C2371: 'size_t': redefinition;different basic types
predefined C++ types (compiler internal)(16): note: see declaration of 'size_t'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\cl.exe"' : return code '0x2'
Stop.
C:\Users\user\Desktop\libsvm-3.23>
What is the wrong with this?

compiling C++ in windows cannot open file 'libcpmt.lib'

I am trying to compile libffm on my windows 10 machine:
https://github.com/guestwalk/libffm
I have Visual Studio Express 2013 installed and am using the VS2013 x64 Cross Tools Command Prompt to try and compile the package.
e:\libffm\nmake -f Makefile.win clean all
Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
erase /Q *.obj *.exe windows\.
rd windows
mkdir windows
cl.exe /nologo /O2 /EHsc /D "_CRT_SECURE_NO_DEPRECATE" /D "USEOMP" /openmp -c ffm.cpp
ffm.cpp
ffm.cpp(1) : warning C4068: unknown pragma
cl.exe /nologo /O2 /EHsc /D "_CRT_SECURE_NO_DEPRECATE" /D "USEOMP" /openmp ffm-train.cpp ffm.obj -Fewindows\ffm-train.exe
ffm-train.cpp
ffm-train.cpp(1) : warning C4068: unknown pragma
LINK : fatal error LNK1104: cannot open file 'libcpmt.lib'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\x86_amd64\cl.exe"' : return code '0x2'
Stop.
I read that it maybe issues with my environment variables so have reinstalled the tools for C++ for VS2013 Express.
When I check the path variables I get:
echo %LIB%
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\amd64;C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64;
echo %LIBPATH%
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\amd64;C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\ExtensionSDKs\Microsoft.VCLibs\12.0\References\CommonConfiguration\neutral;
any ideas what to try next?

Build error with "___report_rangecheckfailure" with OpenSSL libs

Using VC++ 2010
Compiling with OpenSSL libraries to make a SHA512 hash...
getting this build error:
1>------ Build started: Project: Second, Configuration: Debug Win32 ------
1> stdafx.cpp
1> AssemblyInfo.cpp
1>Second.cpp
1> Second.cpp(64): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdio.h(371) : see declaration of 'sprintf'
1> Generating Code...
1> .NETFramework,Version=v4.0.AssemblyAttributes.cpp
1> Microsoft (R) Incremental Linker Version 10.00.40219.01
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> "/OUT:C:\Users\Boss\documents\visual studio 2010\Projects\Second\Debug\Second.exe" /INCREMENTAL "C:\Program Files\OpenSSL-Win32\lib\VC\static\ssleay32MD.lib" "C:\Program Files\OpenSSL-Win32\lib\VC\static\libeay32MD.lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /ASSEMBLYRESOURCE:Debug\Second.Form1.resources /MANIFEST "/ManifestFile:Debug\Second.exe.intermediate.manifest" "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /DEBUG "/PDB:C:\Users\Boss\documents\visual studio 2010\Projects\Second\Debug\Second.pdb" /ASSEMBLYDEBUG /SUBSYSTEM:WINDOWS /TLBID:1 "/ENTRY:main" /DYNAMICBASE /FIXED:NO /NXCOMPAT /MACHINE:X86 Debug\app.res
1> Debug\AssemblyInfo.obj
1> Debug\Second.obj
1> Debug\stdafx.obj
1> "Debug\.NETFramework,Version=v4.0.AssemblyAttributes.obj"
1>libeay32MD.lib(obj_dat.obj) : error LNK2019: unresolved external symbol ___report_rangecheckfailure referenced in function _OBJ_create_objects
1>libeay32MD.lib(b_print.obj) : error LNK2001: unresolved external symbol ___report_rangecheckfailure
1>C:\Users\Boss\documents\visual studio 2010\Projects\Second\Debug\Second.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Tried disabling buffer overrun security check, same error..
Any thoughts? Tried all day with Crypto++, to no avail, OpenSSL was much easier, just hung up on this one error...
It looks as though you are trying to link to OpenSSL libraries that were built with a later version of the compiler.
Function ___report_rangecheckfailure was introduced in more recent versions of Visual Studio (see http://blogs.microsoft.com/cybertrust/2012/01/26/enhancements-to-gs-in-visual-studio-11/ for details).
So the linker is looking in the VS2010 libraries to find a function that didn't exist until later.
The maintainer of at least one of the pre-built OpenSSL libraries for Windows has recently switched from using an earlier version of Visual Studio, which may be the trigger for your problems.
One solution is to build your own OpenSSL Windows binaries with VS2010 (See http://developer.covenanteyes.com/building-openssl-for-visual-studio/ for example).

How to build SHTTPD on Windows?

I tried building SHTTPD on Windows using the following command:
nmake msvc Makefile
All i get is a bunch of errors. What am I doing wrong?
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved. cl /MD /TC /nologo /DNDEBUG /Os standalone.c /link /out:shttpd.exe ws2_32.lib user32.lib advapi32.lib shell32.lib shttpd.lib standalone.c c:\users\samira\desktop\network\shttpd-1.42\src\compat_win32.h(46) : warning C4005: 'EWOULDBLOCK' : macro redefinition C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\errno.h(132) : see previous definition of 'EWOULDBLOCK' –
According to the site you link, you have to use the command
nmake win
to build on windows.
Edit From the site you linked:
Download the source package. Extract
it, go to src directory. Run "make
unix" there ("nmake win" on Windows,
requires MSVC). That buillds a
library.
Have you invoked the command from the src directory?