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的编译自持描述为: 注意:但 ...
随机推荐
- impdp ORA-29913: error in executing ODCIEXTTABLEOPEN callout
1.数据导出时的日志 ;;; Export: Release :: Copyright (c) , , Oracle and/or its affiliates. All rights reserve ...
- (一)使用log4net生成日志文件
1.引入log4net.dll 1.1 Nuget安装 或 http://logging.apache.org/log4net/下载log4net的源代码,编译后把log4net.dll引入项目. 2 ...
- Nginx模块开发1_明白自定义模块的编译流程
自定义模块的编译流程 --add-module参数 configure使用--add-module参数指定添加模块目录. config脚本 由--add-module指定的目录保存为$ngx-addo ...
- iTween基础之Rotate(旋转角度)
一.基础介绍:二.基础属性 原文地址 :http://blog.csdn.net/dingkun520wy/article/details/50696489 一.基础介绍 RotateTo:旋转游戏物 ...
- LintCode-Implement Iterator of Binary Search Tree
Design an iterator over a binary search tree with the following properties: Elements are visited in ...
- 保持程序在后台长时间运行-b
iOS为了让设备尽量省电,减少不必要的开销,保持系统流畅,因而对后台机制采用墓碑式的“假后台”.除了系统官方极少数程序可以真后台,一般开发者开发出来的应用程序后台受到以下限制:1.用户按Home之后, ...
- Robot Framework 环境搭建
一.下载软件 1.安装Python 到官网,下载Python 2.7.9:https://www.python.org/downloads/,最好选择32位版本的(64位系统也支付32位版本),然后安 ...
- 终于明白公测的beta 源自何处了
A very early version of a software product that may not contain all of the features that are planned ...
- StringTokenizer用法
import java.util.StringTokenizer; public class StringTokenizerTest { public static void main(String[ ...
- Codeforces400D Dima and Bacteria
题意:给你一个无向有权的图,图上的点被分成了几类,对于同类的点你需要判断它们之间相互的最短距离是不是0.满足这个条件之后要输出的是类与类之间的最短距离的矩阵.点给到10^5这么多,判断同类的点显然不能 ...