CMake with Win&MinGW
今天一个下午都在做一件简直耻辱play的事情,论文没看,程序没写,玩了一个下午的编译器。。。心塞(逃。。。
言归正传,今天要讲在windows下,使用Cmake和MInGW.
1.g++
MinGW的安装需要首先下载安装器。
然后将安装目录设置成环境变量,以便于cmd在任何目录下都能调用里面的程序。
在安装完成后,在cmd中依次执行:
mingw-get install g++
mingw-get install gdb
F:\C++\cmake\source>g++ main.c -o hello F:\C++\cmake\source>ls
CMakeLists.txt bin hello.exe main.c F:\C++\cmake\source>hello.exe
Hello World!/n
如果你足够细心会发现一个神奇的语句:ls
显然windows的shell是不支持这个语句的,这个功能属于MinGW的副产品。
在安装gcc的时候,不知道怎么还安装了一个msys的文件夹。顺手把它包含到系统环境变量Path中,windows的shell就支持linux的语句了。
至此为止,我们可以使用g++工具编译helloworld了,但是。。。。也就能写个helloworld一类的程序吧。。。。。
2.CMake
其实我对CMake并不陌生,最早相识于PCL,后来也用它配置过OpenCV,再后来还配置过VTK,QT。我真没想到今天在CMake翻了船搞了一下午。。。。。
起因是这样的,像往常一样写好source file.cpp 和 CMakeLists.txt,然后调CMake对程序进行构建,为了能让构建能和ST3尽量符合,我选了之前安装的MinGW作为编译器,而不是以vs2010作为构建输出结果。结果是这样的。。。
F:.
└─source
└─bin
└─CMakeFiles
//这是我的文件结构,source 文件夹下放有源文件。我在bin下执行的cmake
F:\C++\cmake\source\bin>cmake .. -G"MinGW Makefiles"
CMake Error: CMake was unable to find a build program corresponding to "MinGW Ma
kefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a differe
nt build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Ma
kefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a differe
nt build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
0.0居然报错了。。。。好像说MinGW的makefiles有点问题,上SS一查,好像是没装make。
WTF,make不是应该和gcc在一起的么,怎么还要单独安装,结果跑去SF一看,还真是单独的。。
那赶紧下一个然后解压合并到 C:\MinGW 里去。这里是下载地址
ok,然后再重新使用cmake来构建,结果如下:
F:\C++\cmake\source\bin>cmake .. -G"MinGW Makefiles"
-- The C compiler identification is GNU 4.8.
-- The CXX compiler identification is GNU 4.8.
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: F:/C++/cmake/source/bin F:\C++\cmake\source\bin>make
Scanning dependencies of target hello
[ %] Building C object CMakeFiles/hello.dir/main.c.obj
[%] Linking C executable hello.exe
[%] Built target hello F:\C++\cmake\source\bin>hello.exe
Hello World!/n
CMake with Win&MinGW的更多相关文章
- cmake编译win下64位obs
obs是一款开源编码推流工具,简单易用,非常流行.一次项目中,发现本台式机I3处理器下32位obs推流CPU使用率100%.而使用的第三方设备在64位下,性能较好.所以需要编译64位obs并且编译相应 ...
- Clion下载安装使用教程(Win+MinGW)
Clion Jetbrains旗下产品之一,主要用来开发C/C++,软件相比VS来说轻巧很多 一.Clion下载(Crack...) 链接:https://www.bicfic.com/ 你懂的,全英 ...
- Installing xgboost and cmake, mingw64 and mingw
Problem: installing the xgboost to get the python package for later importing
- Windows 下使用 MinGW 和 CMake 进行开发
CMake 是个非常棒的项目管理工具,这已经是毋庸置疑的. 一些小工具需要在 win 下开发,所以今天探索使用 MinGW 和 CMake 在 win 下的搭配使用.简单做记录. MinGW 使用 Q ...
- MariaDB-5.5.33a 编译安装
交代一下内核的信息 [root@localhost soft]# uname -r 2.6.32-71.el6.x86_64 创建mariadb用户组 [root@localhost mariadb- ...
- Qt中添加OpenCV库
配置在Qt中的OpenCV,看了很多“教程”,最终成功.记一下过程. 本机配置: window7 32位系统: qt-opensource-windows-x86-mingw492-5.5.1: Op ...
- Windows下Codeblocks调试Cocos2d-x项目体验(一次失败的体验)
很久之前的一篇文章有介绍过在Ubuntu下安装Cocos2d-x3.11并使用Codeblock调试Cocos2d-x程序:http://www.cnblogs.com/moonlightpoet/p ...
- [QT_OPENCV] qt下opencv配置以及首个opencv工程
使用环境 : window版本 : win7 x64 QT : 5.8 32bit MinGW530 OpenCv : 3.2 opencv在qt下的环境配置: 在百度上百度了许多关于opencv环境 ...
- 使用NDK编译VTK
VTK提供了对安卓的CMAKE编译支持,其介绍文件在源代码根目录下的 "/cmake/android.toolchain.cmake". 对Wndows的编译自持描述为: 注意:但 ...
随机推荐
- openerp 经典收藏 Openerp开发进销存系统完毕总结(转载)
原文地址:http://blog.csdn.net/heartrude/article/details/9142463 Openerp开发进销存系统完毕总结 分类: 代码历程 OpenERP 工程思想 ...
- linux c 验证登录密码
#define _XOPEN_SOURCE #include <stdio.h> #include <unistd.h> int main(int argc, char *ar ...
- Mysql 实例分析连接
表A记录如下: aID aNum 1 a20050111 2 a20050112 3 a20050113 4 ...
- (ACM)C++ STL 训练(第一天)
因为老师说ACM考的是纯C++,所以打算抛弃VS的VC++不用了,针对纯C++的编译器有Intel Compiler(不过要钱),MinGw(个人用的),当然还有微软的VC++ 编译器,IDE你们可以 ...
- [转]unable to resolve superclass of 的奇怪问题和一种解决方法!
[转]unable to resolve superclass of 的奇怪问题和一种解决方法! http://blog.csdn.net/jackymvc/article/details/90015 ...
- C#中类型分析中的常见问题 Type - 转
http://www.cnblogs.com/yuanyuan/archive/2012/08/16/2642281.html 写代码的时候经常需要分析已有类型的信息例如:分析现有类型自动生成类, 或 ...
- java url中文参数乱码问题
http://www.blogjava.net/jerry-zhaoj/archive/2009/07/16/286993.html 转 JAVA 中URL链接中文参数乱码的处理方法JAVA 中URL ...
- C# 该行已经属于另一个表 的解决方法[转]
该文转自:http://blog.sina.com.cn/s/blog_48e4c3fe0100nzs6.html DataTable dt = new DataTable(); dt = ds.Ta ...
- [C/CPP系列知识] 在C中使用没有声明的函数时将发生什么 What happens when a function is called before its declaration in C
http://www.geeksforgeeks.org/g-fact-95/ 1 在C语言中,如果函数在声明之前被调用,那么编译器假设函数的返回值的类型为INT型, 所以下面的code将无法通过编译 ...
- 安装 NoMachine(NX) client and server
(1)Windows上直接安装nxclient-3.5.0-9.exe即可 (2)Linux上 准备linux rpms nxclient-3.5.0-7.x86_64.rpmnxnode-3.5.0 ...