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学习笔记 domain 增加扩展支持,例如支持 <field name="domain">[('type','=','get_user_ht_type()')]</field>
示例代码1,ir_action_window.read : # -*- coding: utf-8 -*-from openerp.osv import fields,osv class res_us ...
- Python默认模块 os和shutil 实用函数
os.sep 可以取代操作系统特定的路径分隔符.windows下为 '\\' os.name 字符串指示你正在使用的平台.比如对于Windows,它是'nt',而对于Linux/Unix用户,它是 ' ...
- 【js】 流式布局 页面
<!DOCTYPE html><html><head> <meta content="text/html; charset=utf-8" ...
- Entity Framework(序)
ADO.NET Entity Framework 是一个对象-关系的映射结构,它提供了ADO.NET的一个抽象,可基于引用的数据库获取对象模型.可以通过Entity Framework 使用不同的变成 ...
- cocos2d-x入门笔记(1)
cocos2d-x的大致开发流程是,首先使用win32版进行代码编写并完成游戏,然后将代码迁移到对应的开发环境上进行交叉编译完成游戏打包,如iphone上是mac+xcode,android是ecli ...
- android开发 PopupWindow 设置充满屏幕
View qrcode_view = this.getLayoutInflater().inflate(R.layout.taskdetail_qrcode,null); final PopupWin ...
- 视频学习_css基础学习
块状元素 block element 容器元素 设置高宽 width height 可以容纳 文本 内脸 和其他块状 霸道 独占一行 特例:form 只容纳 块状元素 常见元素 http:// ...
- UVA 11858 Frosh Week 逆序对统计
题目链接: http://acm.hust.edu.cn/vjudge/contest/122094#problem/H Frosh Week Time Limit:8000MSMemory Limi ...
- maven工程的如何进行代码调试
1.maven项目的父项目右键选择:maven build 注意: 1.选择Browser workspace,让BaseDirectory变成:${***}形式. 2. ...
- Spring实现AOP的4种方式(转)
转自:http://blog.csdn.net/udbnny/article/details/5870076 Spring实现AOP的4种方式 先了解AOP的相关术语:1.通知(Advice):通知定 ...