gpt4 book ai didi

c++ - 尝试设置 openCV、MinGW 编译器时出现 CMake 错误

转载 作者:行者123 更新时间:2023-11-28 06:20:53 25 4
gpt4 key购买 nike

我一直在尝试使用 CMake 构建 openCV,但总是遇到错误。我想我已经正确设置了 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

这会产生以下错误:

-- 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.

我按照 berak 对这个问题的回答中的说明进行操作: Not sure how to build OpenCV for MinGW

请提供一些建议!

提前致谢。

最佳答案

实际上,不需要专门设置编译器和make。所以,调用

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

应该足够了。

如果你真的想指定编译器,你需要设置环境变量CCCXX,这是CMake尊重的:

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

关于c++ - 尝试设置 openCV、MinGW 编译器时出现 CMake 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29332674/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com