program story

CMake가 Visual C ++ 컴파일러를 찾지 못함

inputbox 2020. 7. 30. 10:24
반응형

CMake가 Visual C ++ 컴파일러를 찾지 못함


Visual Studio 2015를 설치하고 이전 프로젝트에서 CMake를 실행 한 후 Cake를 찾을 수 없다는 CMake 오류가 발생했습니다.

The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:4 (PROJECT):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:4 (PROJECT):
  No CMAKE_CXX_COMPILER could be found.

cl.exeVisual Studio 폴더에서 검색하여 C:\Program Files\Microsoft Visual Studio 14.0찾을 수 없었습니다.

Visual Studio 2015가 설치된 Windows에서 CMake를 작동 시키려면 어떻게 설정합니까?


해결책을 찾았습니다. Visual Studio IDE가 성공적으로 설치되었지만 빌드 도구는 설치되지 않았으므로 C ++ 컴파일러는 설치되지 않았습니다.

Visual Studio 2015 GUI에서 C ++ 프로젝트 를 수동으로 만들 려고 시도 하여 C ++ 패키지를 다운로드하라는 메시지를 표시 할 수있었습니다. 그런 다음 CMake는 어려움없이 컴파일러를 찾을 수있었습니다.


나를 위해 일한 해결책은 다음과 같습니다.

  1. 관리자 권한으로 Visual Studio 명령 프롬프트 도구를 엽니 다.
  2. CMake 실행 파일이있는 곳으로 이동하십시오.
  3. Cmake.exe 실행
  4. 빌드 및 소스 폴더를 선택하려면 평소대로 진행하십시오
  5. 적절한 Visual Studio 컴파일러를 선택하고 구성 버튼을 누르십시오

잘만되면 문제없이 실행되어야합니다.


CMakeError.log 파일을보고에 대한 오류를 발견했습니다. cannot run 'rc.exe'

RC.Exe 및 RcDll.Dll을 Microsoft SDK 저장소에서 VC 저장소로 복사하여 CMake가 작동하는 이 답변검색 했습니다.


편집 : 다른 질문에 대한 대답 은 PATH 문제이므로 Microsoft SDK 저장소가 PATH에 있는지 확인하는 것으로 충분합니다.


생성기에서 올바른 버전의 Visual Studio를 사용하고 있는지 확인하십시오. Visual Studio 14를 설치할 때 Visual Studio 15를 잘못 선택했습니다.


Visual Studio 2017 에서이 문제를 해결하는 사람들은 CMake와 관련된 기능이 있으며 관련 컴파일러 도구 세트와 함께 선택하고 설치해야합니다. 아래 스크린 샷을 참조하십시오.

CMake 용 Visaul C ++ 도구가 설치되어 있어야합니다.


위의 해결책 중 어느 것도 효과가 없으면 중지하고 상태 점검을 수행하십시오.

잘못된 -G <config>문자열을 사용하여 화상을 입었 으므로이 잘못된 오류가 발생했습니다.

먼저 일반 명령 프롬프트가 아닌 VS 명령 프롬프트에서 실행하십시오 . 당신은에서 찾을 수 있습니다 Start Menu -> Visual Studio 2015 -> MSBuild Command Prompt for VS2015모든 걸 포기하고이 세트 VS 도구 등에 대한 올바른 경로를

이제 cmake에서 어떤 발전기를 사용할 수 있는지 확인하십시오 ...

cmake -help

...<snip>... The following generators are available on this platform: Visual Studio 15 [arch] = Generates Visual Studio 15 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files. Optional [arch] can be "Win64" or "IA64". ...

그런 다음 [arch]가 추가 된 적절한 문자열 선택하십시오 .

mkdir _build cd _build cmake .. -G "Visual Studio 15 Win64"

하위 디렉토리에서 cmake를 실행하면 해당 디렉토리의 모든 항목을 삭제할 수 있으므로 '깨끗한'작업을 더 쉽게 수행 할 수 있습니다.

Visual Studio 15로 업그레이드했지만 관심을 기울이지 않았으며 2012 년 동안 생성하려고했습니다.


나를 위해 CMakeError.log파일을 확인 하고 다음을 발견했습니다.

[...] 오류 MSB8036 : Windows SDK 버전 8.1을 찾을 수 없습니다. 프로젝트 속성 페이지에서 필요한 버전의 Windows SDK를 설치하거나 SDK 버전을 변경하거나 솔루션을 마우스 오른쪽 단추로 클릭하고 "대상 변경"을 선택하십시오.

이것은 Windows 7에서 Visual Studio 2017을 사용하는 것에도 불구하고 CMake는 Windows 8.1 SDK를 사용하여 탐지 프로젝트를 작성하려고합니다.

Visual Studio 설치 관리자를 사용하여 해당 구성 요소를 추가했으며 이제 CMake는 조개처럼 행복합니다.


메뉴 → Visual Studio 2015 → Visual Studio 2015 용 MSBuild 명령 프롬프트. 그러면 CMake에서 찾을 수 cl.exe있습니다.

set PATH="c:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\";%PATH%

상단 경로를 Windows SDK가 설치된 위치로 변경하십시오.

CMake는 찾을 수 있습니다 rc.exe.

경로로 cd하고 다음 CMakeLists.txt을 수행하십시오.

md .build
cd .build
cmake .. -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release
cmake --build .

이후의 매개 변수 -G는 CMake에서 가져와야합니다. 사용 --help; 발전기가있을 수도 있고 없을 수도 있습니다.


동일한 문제가 발생하여 Visual Studio 설치를 다시 시작하고 다음 옵션을 확인하여 수정했습니다.

Windows and Web Development/ Universal Windows App Development Tools/Windows 10 SDK

여기에는 대부분의 응용 프로그램에서 사용되는 표준 C ++ 헤더가 포함되어 있으므로 종종 설치해야합니다.


Visual Studio 2017을 사용하는 경우 CMake 3.8 이상이 필요합니다!


Visual Studio 2015 Professional을 사용할 때 Windows 10 에서이 문제가 발생했지만 Visual Studio 2015 Express가 작동했습니다! Windows 7에서는 두 Visual Studio 버전이 모두 작동했습니다.

Visual Studio 2015 Professional IDE에서 생성 된 새 프로젝트는 성공적으로 컴파일되지만 CMake는 컴파일러보고를 찾지 못합니다.

The C compiler identification is unknown
The CXX compiler identification is unknown

I upgraded CMake from 3.4.1 to 3.11.4, and now the problem is gone.


In my case there was an environment variable set which was the reason for this error. The problem was solved after deleting cxx_flags from the environment variables.


I got this problem with CMake 3.12.1, after an update of Visual Studio 2017. I simply re-ran CMake and it worked.


In my case I could see in the CMakeError.log that CMake could not find the Windows SDK (MSB8003: Could not find WindowsSDKDir variable from the registry).

The version can be specified on the commandline on the first CMake run using:

-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=

I got further after setting that, but I hit more issues later (so I assume my environment is messed up somehow), but maybe it will help someone with this issue.


A couple of tips:

  • Try to set the path manually by checking 'advanced' and modifying CMAKE_LINKER and CMAKE_MAKE_PROGRAM
  • Delete the cache - in the CMake with GUI go to: File → Delete Cache.

My problem was a combination of previously stated: I have set the compiler version to 15 instead of 14 and when corrected, I had to delete the cache.

I also started the Visual Studio command prompt as an administrator and from there I ran the cmake-gui.exe

Then everything worked as it was supposed to.


In my case the issue was that the parent project, which is including googletest via

add_subdirectory(gtest_dir)

was defined as

PROJECT( projname CXX )

Somehow, CMake does not recognize

PROJECT(sub_project_name CXX C)

since the C compiler is not set in the parent.

I solved the issue by using

PROJECT( projname CXX C)

in my main CMakeLists.txt file.


This might be another solution for those with the latest Windows 10 creator version:

Stack Overflow post Fatal error LNK1104: cannot open file 'gdi32.lib'


None of the previous solutions worked for me. However I noticed that although I installed Visual Studio version 15 (not to be confused with Visual Studio 2015) the directory created on my computer was for Visual Studio 14.

When I specified Visual Studio 14 when I pressed the configuration button it worked.


I had a similar problem with the Visual Studio 2017 project generated through CMake. Some of the packages were missing while installing Visual Studio in Desktop development with C++. See snapshot:

Visual Studio 2017 Packages:

Visual Studio2017 패키지

Also, upgrade CMake to the latest version.


i found this sollution at stackoverflow and i work for me although not working other sollutions if you have a windows 10 OS, doing the following steps will fix the problem:

1) go to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin

2) then copy RC.exe and RcDll from this file

3) go to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin and paste the two files you have copied into it.

thats all i hope it is helpful...


Look in the Cmakelists.txt if you find ARM you need to install C++ for ARM and as well vcvarsall.bat use for ARM bin folder.

It's these packages:

C++ Universal Windows Platform for ARM64 "Not Required"

Visual C++ Compilers and libraries for ARM "Not Required"

Visual C++ Compilers and libraries for ARM64 "Very Likely Required"

Required for finding Threads on ARM 
enable_language(C) 
enable_language(CXX)

Then the problems might disappear:

No CMAKE_C_COMPILER could be found.

No CMAKE_CXX_COMPILER could be found.

If above does not resolve your problem?

Optionally you can remove the options C and CXX in cmakelists.txt by setting # infront of where the enable_language(C) is. And avoid Android ARM processor compilation.


Resolved by adding the missing component Modify->continue add as follow 고치다


I had a related problem: the Visual C++ generators were not even on the list when running cmake --help.

I ran where cmake in console and found that cygwin also provides its own cmake.exe file, which was being used. Changing the order of directories in PATH fixed the problem.


Checking CMakeErrors.log in CMakeFiles returned:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140_xp\Toolset.targets(36,5): warning MSB8003: Could not find WindowsSdkDir_71A variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.

이 오류는 XP 용 빌드 도구 (v140_xp)가 설치되지 않았 음을 의미합니다. 이 문제를 해결하기 위해 Visual Studio 2019 설치 관리자의 개별 구성 요소 탭에서 적절한 기능을 설치했습니다.

여기에 이미지 설명을 입력하십시오


CMake GUI와 VS 21019 Community Edition 에서이 문제가 발생했습니다. CMake 3.15.2를 3.15.3으로 업데이트 한 후 Visual Studio 전에 CMake를 설치했을 수 있습니다. 문제가 사라졌습니다.


CMake는 Visual Studio 컴파일러를 찾을 수 없기 때문입니다. 필요한 컴파일러를 다운로드 할 프로젝트를 시작하면 CMake가이를 찾을 수 있어야합니다.

참고 URL : https://stackoverflow.com/questions/31619296/cmake-does-not-find-visual-c-compiler

반응형