I'm using the latest VS 2019 16.2, which is supposed to have Clang with MSBuild support as well Clang w/ CMake of course.
I installed the CMake components as well as the Clang-cl for v142 build tools (But not the Clang Compiler component that comes with VS!) because I already have Clang compiler v8.0.0 installed in the default path in my system.
I want to use Clang (either through MSBuild or CMake) but both approaches failed.
VS simply doesn't seem to detect my compiler (although the version is supported, supposedly).
Is there a way I can manually make it detect it? May add a path in some options or reinstall clang?
I don't want to install the VS one for my specific reasons.
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.14/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"c:/program files (x86)/microsoft visual studio/2019/community/VC/Tools/Llvm/8.0.0/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/HP/Source/Repos/CMakeProject1/out/build/x64-Clang-Debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_8f083
[1/2] Building C object CMakeFiles\cmTC_8f083.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_8f083.exe
FAILED: cmTC_8f083.exe
cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_8f083.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1422~1.279\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_8f083.dir\testCCompiler.c.obj /out:cmTC_8f083.exe /implib:cmTC_8f083.lib /pdb:cmTC_8f083.pdb /version:0.0 /machine:X86 /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_8f083.dir/manifest.res CMakeFiles\cmTC_8f083.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
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.14/Modules/CMakeTestCCompiler.cmake 60
Related
I was working on a C++ CMake project which was displaying and building fine in Visual Studio. Then I did something, I'm not sure what I did, but it seemed to break CMake. Now I get the following error:
Error CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: E:/DOCS/PROGRAMMING/22-02_Qt/vs_simple/VsConsole5/out/build/x64-debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_c94d5 && [1/2] Building C object CMakeFiles\cmTC_c94d5.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_c94d5.exe
FAILED: cmTC_c94d5.exe
cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_c94d5.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_c94d5.dir\testCCompiler.c.obj /out:cmTC_c94d5.exe /implib:cmTC_c94d5.lib /pdb:cmTC_c94d5.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 ."
LINK Pass 1: command "C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_c94d5.dir\testCCompiler.c.obj /out:cmTC_c94d5.exe /implib:cmTC_c94d5.lib /pdb:cmTC_c94d5.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 /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_c94d5.dir/intermediate.manifest CMakeFiles\cmTC_c94d5.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project. C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake 69
I get this error, even if I make a completely fresh CMake project via File > New > Project > CMake Project from within Visual Studio.
I've tried uninstalling and re-installing:
Visual Studio
Multiple different Windows SDK versions
CMake
I was hoping that doing this would return Visual Studio + CMake to a working state again but I am still getting the same error.
I also tried manually setting LIB and INCLUDE environment variables to the appropriate directories and that did get rid of the error but then the program wouldn't build, I got a bunch of errors like this:
Error (active) E1696 cannot open source file "ctype.h" VsSimple.exe - x64-Debug C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\cctype
I also tried deleting everything in the project folder apart from CMakeLists.txt, the .cpp file and the .h file. Unfortunately still no luck.
the name might be long but that's all I can think of to describe the issue. I was trying to follow a pybind11 tutorial and when I cloned all the examples my intellisense started acting up, first on VSCode with it not fiding the indlude folder (despite adding the path to the "C/C++ configuration") and then on Visual Studio 2022 with Cmake throwing an error when I tried to fix "C++ IntelliSense information may be out of date, generate the CMake cache to refresh".
The error is as follows :
`
Severity Code Description Project File Line Suppression State
Error CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.23/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/jackd/Desktop/exemple_pybind/out/build/x64-Debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_e044f && [1/2] Building C object CMakeFiles\cmTC_e044f.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_e044f.exe
FAILED: cmTC_e044f.exe
cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_e044f.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_e044f.dir\testCCompiler.c.obj /out:cmTC_e044f.exe /implib:cmTC_e044f.lib /pdb:cmTC_e044f.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 /fo CMakeFiles\cmTC_e044f.dir/manifest.res CMakeFiles\cmTC_e044f.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project. C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.23/Modules/CMakeTestCCompiler.cmake 69
`
and since I'm no c++ pro I couldn't figure what this meant.
(I tried the other related topics: here and here)
UPDATE: I attempted some more fixes, which involved installing some new components for visual studio community 2022. However, that didn't work and googling my issue further just brought up conflicting posts regarding RC.exe not being found and CMAKE not working. I'm pretty sure CMAKE is running, because it seems to run everything before failing when attempting to run the ninja -v command. I've been picking at this issue on and off for the last 48 hours with no progress, but I'd really like to get VCPKG working so fingers crossed I can figure out or find a solution.
I've been spending most of the day trying to resolve an issue I have with VCPKG which has caused me to hit a bit of a brick wall with my progress. I used 'git clone' to get a fresh copy of VCPKG onto my computer and I have done a fresh install of Visual Studio Community 2022, however I still run into the same error that I had using Visual Studio Community 2019 when installing a library or dependency using VCPKG. Below I'll post the error log and hopefully that can help showcase the kind of error I'm getting, it seems to be some kind of pathing error with ninja.
After trying to come up with multiple solutions and fixes I just can't seem to get rid of the error, I've tried switching to different versions visual studio along with trying to install different libraries and dependencies. I've also tried fixing the pathing issues through the environment variables, but nothing worked.
This error also appears no matter what library or dependency I try to install, but I basically just want VCPKG to work so I can install libraries and dependencies for my VS Community 2022 project.
Change Dir: C:/src/vcpkg/buildtrees/boost-exception/x64-windows-dbg/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_5c808 && [1/2] Building CXX object CMakeFiles\cmTC_5c808.dir\CMakeCXXCompilerABI.cpp.obj
[2/2] Linking CXX executable cmTC_5c808.exe
FAILED: cmTC_5c808.exe
cmd.exe /C "cd . && C:\src\vcpkg\downloads\tools\cmake-3.22.2-windows\cmake-3.22.2-windows-i386\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_5c808.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_5c808.dir\CMakeCXXCompilerABI.cpp.obj /out:cmTC_5c808.exe /implib:cmTC_5c808.lib /pdb:cmTC_5c808.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 /fo CMakeFiles\cmTC_5c808.dir/manifest.res CMakeFiles\cmTC_5c808.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
Determining if the CXX compiler works failed with the following output:
Change Dir: C:/src/vcpkg/buildtrees/boost-exception/x64-windows-dbg/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_b5aef && [1/2] Building CXX object CMakeFiles\cmTC_b5aef.dir\testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_b5aef.exe
FAILED: cmTC_b5aef.exe
cmd.exe /C "cd . && C:\src\vcpkg\downloads\tools\cmake-3.22.2-windows\cmake-3.22.2-windows-i386\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_b5aef.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_b5aef.dir\testCXXCompiler.cxx.obj /out:cmTC_b5aef.exe /implib:cmTC_b5aef.lib /pdb:cmTC_b5aef.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 /fo CMakeFiles\cmTC_b5aef.dir/manifest.res CMakeFiles\cmTC_b5aef.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
There are plenty of questions and answers relating to this, but none of them have gotten me past my current problem. I can build using CMake/Ninja/clang-cl fine from within Visual Studio, but I want this to be done within a Github Action so I need to be able to do it from the command line - but it fails the configuration stage.
Running from Powershell:
& 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat' x64 10.0.22000.0
cmake -G "Ninja" `
-DVCPKG_TARGET_TRIPLET:STRING="x64-windows-static" `
-DCMAKE_CXX_COMPILER:FILEPATH="C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe" `
-DCMAKE_C_COMPILER:FILEPATH="C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe" `
-DCMAKE_RC_COMPILER:FILEPATH="C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/llvm-rc.exe" `
-DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" `
..\arg_router\
Yields:
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.1.0
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
... VCPKG stuff ...
-- Running vcpkg install - done
-- The CXX compiler identification is Clang 13.0.0 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe
-- Check for working CXX compiler: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe - broken
CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/camde/Documents/workspace/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_81aba && [1/2] Building CXX object CMakeFiles\cmTC_81aba.dir\testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_81aba.exe
FAILED: cmTC_81aba.exe
cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_81aba.dir --rc=C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\Llvm\x64\bin\llvm-rc.exe --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\Llvm\x64\bin\lld-link.exe /nologo CMakeFiles\cmTC_81aba.dir\testCXXCompiler.cxx.obj /out:cmTC_81aba.exe /implib:cmTC_81aba.lib /pdb:cmTC_81aba.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 && cmd.exe /C "cd /D C:\Users\camde\Documents\workspace\build\CMakeFiles\CMakeTmp && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file C:/Users/camde/Documents/workspace/arg_router/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary C:/Users/camde/Documents/workspace/build/CMakeFiles/CMakeTmp/cmTC_81aba.exe -installedDir C:/Users/camde/Documents/workspace/arg_router/vcpkg/installed/x64-windows-static/debug/bin -OutVariable out""
LINK Pass 1: command "C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\Llvm\x64\bin\lld-link.exe /nologo CMakeFiles\cmTC_81aba.dir\testCXXCompiler.cxx.obj /out:cmTC_81aba.exe /implib:cmTC_81aba.lib /pdb:cmTC_81aba.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 /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_81aba.dir/intermediate.manifest CMakeFiles\cmTC_81aba.dir/manifest.res" failed (exit code 1) with the following output:
lld-link: error: could not open 'kernel32.lib': no such file or directory
lld-link: error: could not open 'user32.lib': no such file or directory
lld-link: error: could not open 'gdi32.lib': no such file or directory
lld-link: error: could not open 'winspool.lib': no such file or directory
lld-link: error: could not open 'shell32.lib': no such file or directory
lld-link: error: could not open 'ole32.lib': no such file or directory
lld-link: error: could not open 'oleaut32.lib': no such file or directory
lld-link: error: could not open 'uuid.lib': no such file or directory
lld-link: error: could not open 'comdlg32.lib': no such file or directory
lld-link: error: could not open 'advapi32.lib': no such file or directory
lld-link: error: could not open 'msvcrtd.lib': no such file or directory
lld-link: error: could not open 'oldnames.lib': no such file or directory
ninja: build stopped: subcommand failed.
Those libraries are installed in C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x64 which I would have thought vcvarsall.bat would have setup some env var that points to them - but clearly it didn't. What's weirder is that when I configure CMake from within VS, it doesn't need to pass the CMAKE_RC_COMPILER arg but if I don't then it fails stating that rc.exe can't be found.
Clearly VS is doing some extra configuration in the background before CMake is configured - what is it!?
As an extra data point, if I try to run the above CMake configuration command within the 'Developer Powershell for VS 2022', it fails for a different reason:
-- Running vcpkg install - done
-- The CXX compiler identification is Clang 13.0.0 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe
-- Check for working CXX compiler: C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe - broken
CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/camde/Documents/workspace/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_3b037 && [1/2] Building CXX object CMakeFiles\cmTC_3b037.dir\testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_3b037.exe
FAILED: cmTC_3b037.exe
cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_3b037.dir --rc=C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\Llvm\x64\bin\llvm-rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\mt.exe --manifests -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\Llvm\x64\bin\lld-link.exe /nologo CMakeFiles\cmTC_3b037.dir\testCXXCompiler.cxx.obj /out:cmTC_3b037.exe /implib:cmTC_3b037.lib /pdb:cmTC_3b037.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 && cmd.exe /C "cd /D C:\Users\camde\Documents\workspace\build\CMakeFiles\CMakeTmp && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file C:/Users/camde/Documents/workspace/arg_router/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary C:/Users/camde/Documents/workspace/build/CMakeFiles/CMakeTmp/cmTC_3b037.exe -installedDir C:/Users/camde/Documents/workspace/arg_router/vcpkg/installed/x64-windows-static/debug/bin -OutVariable out""
LINK Pass 1: command "C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\Llvm\x64\bin\lld-link.exe /nologo CMakeFiles\cmTC_3b037.dir\testCXXCompiler.cxx.obj /out:cmTC_3b037.exe /implib:cmTC_3b037.lib /pdb:cmTC_3b037.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 /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_3b037.dir/intermediate.manifest CMakeFiles\cmTC_3b037.dir/manifest.res" failed (exit code 1) with the following output:
lld-link: error: <root>: undefined symbol: mainCRTStartup
ninja: build stopped: subcommand failed.
I have the following C++ build setup (using MSVC 2019 + Ninja):
build.bat
#echo off
mkdir build_folder
cd build_folder
call "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.21.27702/bin/HostX64/x64/cl.exe" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.21.27702/bin/HostX64/x64/cl.exe" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" ..
cd ..
CMakeLists.txt
cmake_minimum_required (VERSION 3.13)
project(TestScript CXX)
set(CMAKE_CXX_STANDARD 17)
add_executable(${PROJECT_NAME} Script.cpp)
Script.cpp
int main()
{
return 0;
}
But when running build.bat I get this output:
-- The CXX compiler identification is MSVC 19.21.27702.2
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.21.27702/bin/HostX64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.21.27702/bin/HostX64/x64/cl.exe -- broken
CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.14/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.21.27702/bin/HostX64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Coding/cmake_msvc_test/build_folder/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_6ecce
[1/2] Building CXX object CMakeFiles\cmTC_6ecce.dir\testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_6ecce.exe
FAILED: cmTC_6ecce.exe
cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_6ecce.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MIB055~1\2019\PROFES~1\VC\Tools\MSVC\1421~1.277\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_6ecce.dir\testCXXCompiler.cxx.obj /out:cmTC_6ecce.exe /implib:cmTC_6ecce.lib /pdb:cmTC_6ecce.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_6ecce.dir/manifest.res CMakeFiles\cmTC_6ecce.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
I assume my cmake ninja call in build.bat is not quite correct (in terms of includes & compiler paths, etc). How would I need to tweak it?