简体   繁体   中英

CMake error trying to setup openCV, MinGW compiler

I've been trying to build openCV using CMake, but keep running into errors. I think I have MinGW setup properly.

I'm running the following command in C:\\opencv\\build\\x86\\mingw:

cmake -G "MinGW Makefiles" -D CMAKE_CXX_COMPILER=mingw32-g++.exe -D CMAKE-MAKE_PROGRAM=mingw32-make.exe ../../../sources

This gives the following error:

-- The CXX compiler identification is GNU 4.8.1 -- The C compiler identification is GNU 4.8.1 -- Check for working CXX compiler: C:/MinGW/bin/mingw32-g++.exe CMake Error: Generator: execution of make failed. Make command was: "mingw32-make.exe" "cmTryCompileExec1510977625/fast" -- Check for working CXX compiler: C:/MinGW/bin/mingw32-g++.exe -- broken CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/CMakeTestCXXCompiler.cmake:54 (message): The C++ compiler "C:/MinGW/bin/mingw32-g++.exe" is not able to compile a simple test program.

It fails with the following output:

 Change Dir: C:/opencv/build/x86/mingw/CMakeFiles/CMakeTmp 

Run Build Command: "mingw32-make.exe" "cmTryCompileExec1510977625/fast"

The system cannot find the file specified

Generator: execution of make failed.

I was following the instructions found in berak's response to this question: Not sure how to build OpenCV for MinGW

Please provide some suggestions!

Thanks in advance.

Actually, it should not be necessary to set your compiler and make specifically. So, calling

$ cmake -G "MinGW Makefiles" ../../../sources

should be enough.

If you really want to specify the compiler, you need to set the environment variables CC and CXX , which CMake respects:

$ export CC=/absolute/path/to/your/mingw32-gcc.exe
$ export CXX=/absolute/path/to/your/mingw32-g++.exe
$ cmake -G "MinGW Makefiles" ../../../sources

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM