在windows上使用cmake來c++的程序,遇到一個問題
問題排查
試過在電腦上單獨使用gcc是可以編譯成功的,那么就可能是IDE集成的問題了
IDE的編譯工具鏈從mingw換成vs,編譯通過
讓clion以管理員身份運行
問題日志
The output was:
請求的操作需要提升。
Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler":
Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler":
Determining if the C compiler works failed with the following output:
Change Dir: E:/Code/cpp_study/mycpp/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/mingw64/bin/mingw32-make.exe cmTC_4a2bf/fast && 請求的操作需要提升。
Generator: execution of make failed. Make command was: C:/mingw64/bin/mingw32-make.exe cmTC_4a2bf/fast &&
重開clion之后的日志如下:
無法獲取編譯器信息:
Cannot run program "C:\mingw64\bin\gcc.exe" (in directory "E:\Code\cpp_study\clion\cmake-build-debug"): CreateProcess error=740, 請求的操作需要提升。
最終凶手
從windows defender掃描中排除 IDE 和項目目錄: E:\Code\cpp_study\clion C:\Users\admin\AppData\Local\JetBrains\CLion2020.3 或將 IDE 進程添加為排除項。
解決辦法:把windows defender徹底關閉吧,同樣在安全中心添加排除進程和目錄。
另一個問題,如下。這個問題的解決辦法就是重新Make一次就好啦。
process_begin: CreateProcess(C:\Program Files\JetBrains\CLion 2020.3.1\bin\cmake\win\bin\cmake.exe, "C:\Program Files\JetBrains\CLion 2020.3.1\bin\cmake\win\bin\cmake.exe" -E cmake_progress_start E:\Code\cpp_study\clion\cmake-build-debug\CMakeFiles 0, ...) failed.
make (e=5): 拒絕訪問。
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:103: CMakeFiles/arrAndPointTest.dir/rule] Error 5
mingw32-make.exe: *** [Makefile:137: arrAndPointTest] Error 2
