Windows下CLion搭配MinGW时CMake运行报错求助
Hey there! I’ve run into this exact hiccup before with older MinGW versions and CLion. Let’s break down what’s going wrong and how to fix it.
First, let’s zero in on the critical error line from your log that reveals the root cause:
process_begin: CreateProcess(C:\Users\noName\AppData\Local\Temp\make2428-1.bat, C:\Users\noName\AppData\Local\Temp\make2428-1.bat, ...) failed.
make (e=2): El sistema no puede encontrar el archivo especificado.
This means mingw32-make.exe can’t locate the temporary batch file CMake generates to test your compiler. Here are the most effective fixes to try:
1. Verify MinGW Environment & Path Priority
- Double-check that your MinGW
bindirectory (e.g.,C:/MinGW/bin) is at the top of your WindowsPATHenvironment variable. Sometimes other tools (like Git Bash or another compiler) add their owngcc/maketo the PATH first, causing conflicts. - Confirm
mingw32-make.exeexists inC:/MinGW/bin. If it’s missing, re-install MinGW and make sure to select the "MinGW Make Tools" component during setup.
2. Manually Specify Compiler & Make Program in CLion
CLion’s auto-detection might miss key paths. Let’s force it to use your MinGW tools directly:
- Open CLion and go to
File > Settings > Build, Execution, Deployment > CMake - In the
CMake optionsfield, add these lines (adjust paths to match your MinGW installation):-DCMAKE_C_COMPILER=C:/MinGW/bin/gcc.exe -DCMAKE_CXX_COMPILER=C:/MinGW/bin/g++.exe -DCMAKE_MAKE_PROGRAM=C:/MinGW/bin/mingw32-make.exe - Click
ApplythenOK, then re-run the CMake configuration (click the "Reload CMake Project" button in the top-right toolbar).
3. Check for Antivirus/Defender Interference
Windows Defender or third-party antivirus tools often flag temporary batch files created by CMake as suspicious and block/delete them. Try temporarily disabling your antivirus, then re-run the CMake detection. If it works, add the C:/Users/noName/AppData/Local/Temp directory to your antivirus’ exclusion list.
4. Upgrade MinGW & CMake
Your MinGW version (6.3.0) is quite outdated, and older releases have known compatibility issues with newer CMake/CLion versions. Consider upgrading to a newer MinGW-w64 distribution (it supports both 32-bit and 64-bit systems). You can also update CMake within CLion: go to File > Settings > Build, Execution, Deployment > CMake and select a newer version from the CMake executable dropdown (CLion may offer to download the latest version automatically).
5. Fix Temporary Directory Permissions
Ensure your user account has full read/write permissions to the C:/Users/noName/AppData/Local/Temp directory. Restricted permissions can prevent CMake from creating the necessary temporary files. Right-click the Temp folder, go to Properties > Security > Edit, and grant your user account "Full Control" access.
Try these steps one by one—usually adjusting the CMake options or fixing PATH priority resolves the issue quickly.
内容的提问来源于stack exchange,提问作者Islen

