简体   繁体   English

尝试设置openCV,MinGW编译器时出现CMake错误

[英]CMake error trying to setup openCV, MinGW compiler

I've been trying to build openCV using CMake, but keep running into errors. 我一直在尝试使用CMake构建openCV,但是一直遇到错误。 I think I have MinGW setup properly. 我认为我的MinGW设置正确。

I'm running the following command in C:\\opencv\\build\\x86\\mingw: 我在C:\\ opencv \\ build \\ x86 \\ mingw中运行以下命令:

cmake -G "MinGW Makefiles" -D CMAKE_CXX_COMPILER=mingw32-g++.exe -D CMAKE-MAKE_PROGRAM=mingw32-make.exe ../../../sources 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. -CXX编译器标识为GNU 4.8.1-C编译器标识为GNU 4.8.1-检查工作的CXX编译器:C:/ MinGW / bin / mingw32-g ++。exe CMake错误:生成器:执行make失败。 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. Make命令为:“ mingw32-make.exe”“ cmTryCompileExec1510977625 / fast”-检查工作的CXX编译器:C:/ MinGW / bin / mingw32-g ++。exe-C:/ Program Files(x86)处的CMake错误。 /CMake/share/cmake-3.2/Modules/CMakeTestCXXCompiler.cmake:54(消息):C ++编译器“ C:/ MinGW / bin / mingw32-g ++。exe”无法编译简单的测试程序。

It fails with the following output: 它失败,并显示以下输出:

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

Run Build Command: "mingw32-make.exe" "cmTryCompileExec1510977625/fast" 运行构建命令:“ mingw32-make.exe”“ cmTryCompileExec1510977625 / fast”

The system cannot find the file specified 该系统找不到指定的文件

Generator: execution of make failed. 生成器:make执行失败。

I was following the instructions found in berak's response to this question: Not sure how to build OpenCV for MinGW 我遵循了berak对以下问题的答复中的说明: 不知道如何为MinGW构建OpenCV

Please provide some suggestions! 请提供一些建议!

Thanks in advance. 提前致谢。

Actually, it should not be necessary to set your compiler and make specifically. 其实,它不应该有必要设置你的编译器和make明确。 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: 如果确实要指定编译器,则需要设置CMake注意的环境变量CCCXX

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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