用git为Windows,MinGW和make制作cmake [英] cmake with git for windows, MinGW and make

查看:164
本文介绍了用git为Windows,MinGW和make制作cmake的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我从 https://sourceforge.net/projects/mingw/files/安装了MinGW 以及带有它的mingw32-gcc-g ++和mingw32-gcc-objs.我已经在路径中添加了C:\ MinGW \ bin.

Firstly, I have installed MinGW from https://sourceforge.net/projects/mingw/files/ and the mingw32-gcc-g++ and mingw32-gcc-objs with it. I have added C:\MinGW\bin to my path.

第二,我已经为Windows安装了Git(不是很重要,在cmd.exe上结果是相同的.)

Secondly, I have installed Git for windows (not really important, the result is the same on cmd.exe).

第三,我已经使用 http://gnuwin32.sourceforge安装了完整的软件包"make". net/packages/make.htm

在那之后,我在.msi上安装了cmake 3.5.1.

After that, I have installed cmake 3.5.1 with the .msi.

但是当我运行cmake ../src时,结果是:

But when I run cmake ../src the result is :

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:5 (project):
No CMAKE_C_COMPILER could be found.



CMake Error at CMakeLists.txt:5 (project):
  No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred!
See also "C:/Users/pauka/Dropbox/ETUDE/SRI/S8/STA_Stage/sources/tests/bin/CMakeFiles/CMakeOutput.log".
See also "C:/Users/pauka/Dropbox/ETUDE/SRI/S8/STA_Stage/sources/tests/bin/CMakeFiles/CMakeError.log".

因此cmake找不到gcc或g ++.但是,当我运行gcc -version时,输出是好的...我应该为cmake配置什么?

So cmake can't find gcc or g++. But when I run gcc -version, the output is good... What should I configure for cmake ?

我的CMakeLists.txt是:

My CMakeLists.txt is :

# Ajustez en fonction de votre version de CMake
cmake_minimum_required (VERSION 2.8)

# Nom du projet
project (main)

find_package (OpenCV REQUIRED)

# Exécutable "main", compilé à partir du fichier main.cpp
add_executable (tracking_color tracking_color.cpp)
add_executable (feuille feuille.cpp)
add_executable (detect_circles detect_circles.cpp)
add_executable (segmentation segmentation.cpp)
add_executable (watershed_perso watershed_perso.cpp)
add_executable (main main.cpp utils.h)
add_executable (info_coins info_coins.cpp)

# main sera linké avec les bibliothèques d'OpenCV
target_link_libraries (tracking_color ${OpenCV_LIBS})
target_link_libraries (feuille ${OpenCV_LIBS})
target_link_libraries (detect_circles ${OpenCV_LIBS})
target_link_libraries (segmentation ${OpenCV_LIBS})
target_link_libraries (watershed_perso ${OpenCV_LIBS})
target_link_libraries (info_coins ${OpenCV_LIBS})
target_link_libraries (main ${OpenCV_LIBS})

推荐答案

好,对我感到羞耻,

我必须重新启动计算机,然后在CMake GUI中选择"MinGW Makefiles".单击配置,然后单击生成".

I had to restart my computer and select "MinGW Makefiles" in the CMake GUI. Click configure, and after that "Generate".

接下来,您切勿使用"Windows的Git",因为其中包含"sh.exe",这是一个cmake的错误.

Next, you must not use "Git for windows" because there is "sh.exe" and it's a cmake bug.

PS:要使用OpenCV,必须对其进行编译:

PS: to use OpenCV, you must compile it :

cd C:\opencv
mkdir my_build
cd my_build
cmake -G "MinGW Makefiles" ../sources
mingw32-make # took 2 hours on my computer

然后将C:\ opencv \ my_build和C:\ opencv \ my_build \ bin添加到系统路径.

and next add, C:\opencv\my_build and C:\opencv\my_build\bin to the system path.

这篇关于用git为Windows,MinGW和make制作cmake的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆