Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build mingw64 error #5917

Open
missionsave opened this issue Feb 21, 2025 · 1 comment
Open

build mingw64 error #5917

missionsave opened this issue Feb 21, 2025 · 1 comment

Comments

@missionsave
Copy link

error log | 日志或报错信息 | ログ

CMake Error: Could not create named generator MinGW Makefiles

how to reproduce | 复现步骤 | 再現方法

cmake -DNCNN_VULKAN=ON -G "MinGW Makefiles" ..

@nihui
Copy link
Member

nihui commented Feb 21, 2025

To resolve the CMake Error: Could not create named generator MinGW Makefiles, follow these steps:

1. Verify MinGW Installation

Ensure MinGW (preferably MinGW-w64) is installed correctly. Check if mingw32-make.exe, gcc.exe, and g++.exe exist in the MinGW\bin directory (e.g., C:\Qt\Qt5.12.11\Tools\mingw730_64\bin).

2. Set Environment Variables

Add the MinGW bin directory to your system PATH:

  • Right-click This PCPropertiesAdvanced system settingsEnvironment Variables → Edit PATH → Add the MinGW bin path (e.g., C:\MinGW\bin).

3. Explicitly Specify Generator and Compiler Paths

Run CMake with the MinGW Makefiles generator and define compiler paths explicitly:

cmake -G "MinGW Makefiles" \
      -DCMAKE_MAKE_PROGRAM="C:/MinGW/bin/mingw32-make.exe" \
      -DCMAKE_C_COMPILER="C:/MinGW/bin/gcc.exe" \
      -DCMAKE_CXX_COMPILER="C:/MinGW/bin/g++.exe" \
      <source_path>

4. Clean Build Cache

Delete CMakeCache.txt and the CMakeFiles directory if you previously used a different generator (e.g., Visual Studio).

5. Handle Large File Compilation (Optional)

If encountering too many sections errors, add -Wa,-mbig-obj to CMAKE_CXX_FLAGS in CMake:

cmake ... -DCMAKE_CXX_FLAGS="-Wa,-mbig-obj"

Verification

Check toolchain validity:

gcc --version      # Should show GCC version
mingw32-make --version  # Should show Make version

Then compile using mingw32-make.

Notes

  • Avoid spaces or non-ASCII characters in paths.
  • For Qt’s MinGW, ensure paths match (e.g., C:/Qt/Qt5.12.11/Tools/mingw730_64/bin).

If the issue persists, reinstall MinGW or use CMake GUI to configure paths interactively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants