windows 下面make的使用示例
---恢复内容开始---
前面已经安装了windows下面的编译器g++和mingw32-make,下面就make做个示例说明
1.文档结构
|--src
|--comm
|--comm.cpp(内容如下:)
#include "../include/comm.h"
string trim(string &strIn)
{
string tmp = " ";
strIn.erase(strIn.find_last_not_of(tmp)+,strIn.size()-strIn.find_last_not_of(tmp));
strIn.erase(,strIn.find_first_not_of(tmp));
return strIn;
}
|--Makefile(内容如下:)
libcomm.a:comm.o
ar -r libcomm.a comm.o
move libcomm.a ..\..\lib
comm.o:comm.cpp
g++ -m64 -c comm.cpp -o comm.o
|--include
|--comm.h(内容如下:)
#ifndef _COMM_H__
#define _COMM_H__
#include <iostream>
using namespace std;
string trim(string &strIn);
#endif
|--module
|--test
|--Makefile
test.exe:test.cpp
g++ -m64 -I../../include -L../../../lib test.cpp -lcomm -o test.exe
move ./test.exe ../../../bin/
|--test.cpp(内容如下:)
#include <iostream>
#include "..\..\include\comm.h"
using namespace std; int main()
{
//cout<<"Hello World!"<<endl;
string hello = " Hello World! ";
cout<<trim(hello)<<endl;
return ;
}
|--lib
|--bin
2.执行顺序
2.1先到comm(src\comm)下面编译出来.o 和.a 文件,然后把.a移动到lib目录下面
cd src
cd common
mingw32-make
结果如下所示:
your current path>mingw32-make
g++ -m64 -c comm.cpp -o comm.o
ar -r libcomm.a comm.o
ar: creating libcomm.a
move libcomm.a ..\..\lib
移动了 1 个文件。
yout current path>
2.2到test目录(src\module\test)下面编译出来可执行文件,然后把可执行文件移动到bin目录下面:
your current path>mingw32-make
g++ -m64 -I../../include -L../../../lib test.cpp -lcomm -o test.exe
move ./test.exe ../../../bin/
移动了 1 个文件。
your current path>
2.3到bin下面去执行test.exe
your current path>test.exe
Hello World!
your current path>
2.4至此,hello world执行完毕。
3.我这里执行用的是mingw64,make用的是mingw32-make。
使用mingw64下面的g++的时候,执行move命令没有问题,需要加-m64参数(如果OS是64位,推荐使用这个,32位未作测试)
使用mingw32下面的g++的时候,生成的可执行文件也没有问题,但是执行dos命令move就会报错,可以不加参数,默认是-m32.
windows 下面make的使用示例的更多相关文章
- Appium(JAVA)Windows 7系统搭建及示例运行
Appium(JAVA)Windows 7系统搭建及示例运行 分类: Appium 2014-11-14 17:44 4323人阅读 评论(2) 收藏 举报 1.搭建Android环境 http:// ...
- Windows Store App Image开发示例
通过上面的介绍,读者已经了解了Image对象及ImageBrush对象的使用方法和常用属性,在实际的开发工作中,比较常用的是Image对象,下面以一个幼儿园识物识字卡应用为例,来帮助读者更好的理解Im ...
- Android学习笔记—Windows下NDK开发简单示例
该示例假设Android开发环境已经搭建完成,NDK也配置成功: 1.在Eclipse上新建Android工程,名称为ndkdemo.修改res\layout\activity_main.xml &l ...
- winreg操作windows注册表详解示例
#coding:utf-8 #=====================================================================#=====本程序演示了WINR ...
- 【python】python彻底卸载的方法【windows安装版卸载的示例】
要想彻底干净的卸载python,如果是使用的安装版的话,其实很简单.[windows安装版] 就是点击安装包. 例如,当前你安装的版本是3.6.5,你想要把它卸载掉. 查看python版本的命令: 只 ...
- Windows Phone SplashScreen初始屏幕示例
protected override void OnLaunched(LaunchActivatedEventArgs args) { if (args.PreviousExecutionState ...
- windows下kafka配置入门 示例
实验平台与软件: 操作系统:windows7 32 位 java 开发包: jdk1.8.0_144 集群: zookeeper-3.3.6 消息队列: kafka_2.11-0.11.0.1 安装 ...
- 在Windows如何解决下Cocos2d-x示例代码TestCpp我找不到lib问题库文件
遇到此问题,首先确定失踪的库文件,然后找到文件夹,库文件. 在编制Cocos2d-x在TestCpp工程,提示缺少lib文件,共同拥有下面2种可靠解决方式: 1.在Cocos2d-x的根文件夹Debu ...
- 背水一战 Windows 10 (5) - UI: 标题栏
[源码下载] 背水一战 Windows 10 (5) - UI: 标题栏 作者:webabcd 介绍背水一战 Windows 10 之 UI 标题栏 示例TitleBarDemo.xaml <P ...
随机推荐
- PHP中的面向对象思想
<?php header("Content-Type: text/html; charset=gb2312"); class person{ /** * 成员属性 * 在类中 ...
- James Munkres Topology: Theorem 19.6
Theorem 19.6 Let \(f: A \rightarrow \prod_{\alpha \in J} X_{\alpha}\) be given by the equation \[ f( ...
- Vue前端利用qrcode生成二维码
<div id="qrcode" style="width: 560px;height: 560px;background-color: white;"& ...
- Xshell 连接 vmware中的CentOS 7
参考内容: Xshell 连接 CentOS 7 与 Ubuntu Server,http://www.linuxidc.com/Linux/2017-03/141333.ht ...
- 虚拟机Oracle VM VirtualBox linux系统如何访问windows共享文件夹
1. 在本机系统设置一个共享文件夹,用于与Ubuntu交互的区域空间. 2.右击状态栏上共享文件夹图标或菜单栏“设备-共享文件夹”,打开共享文件夹设置,如图示 3.点击共享文件夹设置框,右 ...
- Windows的四类消息
Windows的三类消息1.标准消息宏名称 对映消息 消息处理函数(名称已由系统预设)ON_WM_CHAR WM_CAHR OnCharON_WM_CLOSE WM_CLOSE OnCloseON_W ...
- Linux命令行参数前加--,-和不加杠
参数前“-”的表明后面的参数是字符形式. 参数前“--”的则表明后面的参数是单词形式. 参数前有横的是System V风格. 参数前没有横的是BSD风格.
- 04-JQuery
今日任务 使用JQuery完成页面定时弹出广告 定时器: setInterval clearInterval setTimeout clearTimeout 显示: ...
- Egret--设置全屏,控制浏览器全屏
1, 手机浏览器打开的项目的时候,浏览器的虚拟按键/标题栏, 使得即便设置全屏也没有变成全屏(好像JS 中有方法向浏览器请求全屏) 2, 加载资源, 关闭后卸载, 再次进入游戏依然很快.不过登陆游戏的 ...
- C/C++中的内存对齐问题和pragma pack命令详解
这个内存对齐问题,居然影响到了sizeof(struct)的结果值.突然想到了之前写的一个API库里,有个API是向后台服务程序发送socket请求.其中的socket数据包是一个结构体.在发送soc ...