CMake与MinGW以及Eclipse CDT的使用

5
我正在尝试在Windows 7(64位)上使用Cmake编译OpenCV。它将与Eclipse和CDT一起使用,据我在某处阅读到的,无论使用何种编译器,都必须指定Unix Makefiles。 现在,鉴于我也有cygwin(用于Android NDK),我首先尝试使用其编译器,并成功配置了CMake并生成了makefile,但只编译到63%时,OpenCV就会报错(关于ffmpeg和HMODULE)。因此,我切换到MinGW(使用HelloWorld也很痛苦,不管PATH变量设置如何,都必须指定完整路径到MinGW g++),但现在我甚至无法配置CMake。我收到以下错误消息:
The C compiler identification is GNU
The CXX compiler identification is GNU
CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found. Please set         CMAKE_RC_COMPILER to a valid compiler path or name.
Check for working C compiler: C:/MinGW/bin/gcc.exe
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeRCInformation.cmake:22 (GET_FILENAME_COMPONENT):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-GNU.cmake:59 (enable_language)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-GNU-C.cmake:1 (include)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:56 (INCLUDE)
CMakeLists.txt:2 (PROJECT)

CMake Error: CMAKE_RC_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test program.

It fails with the following output:

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:47 (project)

Configuring incomplete, errors occurred!

如果有人知道可能存在的问题(与cygwin shell冲突?),我将非常感激任何输入。提前感谢!
2个回答

6
我们在使用“Unix Makefiles”生成器时遇到了同样的问题。我们通过使用“MSYS Makefiles”生成器来解决它(Msys是围绕MinGW的shell环境,类似于一个非常小的cygwin)。

谢谢,这就解决了!我想我找到的关于Eclipse CDT中Unix Makefiles的信息已经过时了,再加上我被可用的CDT选项误导了,没有考虑其他选择。OpenCV已经编译完成,希望现在能够在Eclipse中正常工作。干杯! - vkotor

3

这个错误信息文本:

CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found.
  Please set CMAKE_RC_COMPILER to a valid compiler path or name.

这表示 "windres" (用于mingw和cygwin基于gcc的构建树)不在PATH中。

CMake 2.8.4最近添加了对windres的支持,以编译Windows资源(*.rc)文件。也许在您的MinGW环境中没有可用的windres?


实际上,windres已经存在了,并且它的目录与MinGW make的目录相同,已经包含在PATH中。但也许你指出的问题与我在编译HelloWorld时不得不包含MinGW的完整路径有关,无论PATH设置如何。无论如何,看起来Rudi的解决方案至少现在可以解决这个问题。 - vkotor

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接