今天在本地看到一个lsd_1.6的源文件,不知道什么时候看LSD时下载的,里面只有一个Makefile和源文件。

想到在Linux下可以只用一个make命令就可以得到可执行程序,在Windows下是不是以可以一个命令就得到EXE程序呢,想到了nmake。

原来的Makefile是这样写的:

 # -----------------------------------------------------------------------------
#
# LSD - Line Segment Detector on digital images
#
# Copyright (c) - rafael grompone von gioi <grompone@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ----------------------------------------------------------------------------- all: lsd lsd_call_example lsd: lsd.c lsd.h lsd_cmd.c
cc -O3 -o lsd lsd_cmd.c lsd.c -lm lsd_call_example: lsd.c lsd.h lsd_call_example.c
cc -o lsd_call_example lsd_call_example.c lsd.c -lm doc: lsd.c lsd.h doxygen.config
doxygen doxygen.config clean:
rm -f lsd lsd_call_example cleandoc:
rm -rf doc # -----------------------------------------------------------------------------

由于自己也不怎么会使用nmake就抱着试试看的态度试了一把。

去windows下打开这个:

然后 执行下面的命令,进入到lsd_1.6目录下:

cd /d D:\GitHub\lsd_1.

进入目录后执行编译命令:

nmake -f Makefile

接着就撞见错误了:

 D:\GitHub\lsd_1.>nmake -f Makefile

 Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved. cc -O3 -o lsd lsd_cmd.c lsd.c -lm
'cc' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
NMAKE : fatal error U1077: 'cc' : return code '0x1'
Stop.

原来是nmake不认识cc,果然不是一家人,联想到vs使用的编译命令是cl,果断把cc替换成cl,然后新建了一个Makefile1,只把原来Makefile里面的cc替换成cl.

Makefile1内容如下:

 # -----------------------------------------------------------------------------
#
# LSD - Line Segment Detector on digital images
#
# Copyright (c) - rafael grompone von gioi <grompone@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ----------------------------------------------------------------------------- all: lsd lsd_call_example lsd: lsd.c lsd.h lsd_cmd.c
cl -O3 -o lsd lsd_cmd.c lsd.c -lm lsd_call_example: lsd.c lsd.h lsd_call_example.c
cl -o lsd_call_example lsd_call_example.c lsd.c -lm doc: lsd.c lsd.h doxygen.config
doxygen doxygen.config clean:
rm -f lsd lsd_call_example cleandoc:
rm -rf doc # -----------------------------------------------------------------------------

接着使用编译命令:

nmake -f Makefile1

就这样编译通过了:

 D:\GitHub\lsd_1.>nmake -f Makefile1

 Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved. cl -O3 -o lsd lsd_cmd.c lsd.c -lm
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved. cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9002 : ignoring unknown option '-O3'
cl : Command line warning D9002 : ignoring unknown option '-lm'
lsd_cmd.c
lsd.c
Generating Code...
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved. /out:lsd_cmd.exe
/out:lsd.exe
lsd_cmd.obj
lsd.obj
cl -o lsd_call_example lsd_call_example.c lsd.c -lm
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved. cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9002 : ignoring unknown option '-lm'
lsd_call_example.c
lsd.c
Generating Code...
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved. /out:lsd_call_example.exe
/out:lsd_call_example.exe
lsd_call_example.obj
lsd.obj

注意:其实makefile中应该还有其他需要修改的,但是简单编译一个exe已经实现了,至于其他需要修改的有时间再研究。

Windows使用nmake和Makefile编译c++的更多相关文章

  1. windows下如何使用makefile编译

    1. 编写makefile. 2. 使用nmake进行编译, vs2010或者其他都是用nmake进行编译的,将bin目录添加到path环境变量中 先执行vcvars32.bat 再执行nmake

  2. 在 Windows下用 Visual Studio 编译 OpenSSL 1.1.0

    到OpenSSL官方网站下载OpenSSL源代码包 1.下载 openssl-1.1.0.tar.gz 2.安装 ActivePerl, 可以到http://www.activestate.com/a ...

  3. Win7 + VS2015 + CMake3.6.1-GUI + Makefile 编译开源库

    CMake生成Unicode版本VC工程 Just add this line in your top CMakeLists.txt file:     add_definitions(-DUNICO ...

  4. 【VS开发】【数据库开发】libevent windows下基于VS2010的编译

    libevent是一个常用的网络库,下面就看看在windows下面编译测试的过程吧. 一 环境 系统:win8.1编译器:VS2013官方下载地址:http://libevent.org/版本:2.0 ...

  5. Windows 内核(WRK)编译

    引子 WRK 是微软于 2006 年针对教育和学术界开放的 Windows 内核的部分源码, WRK(Windows Research Kernel)也就是 Windows 研究内核, 在 WRK 中 ...

  6. VS环境下的makefile编译

    直接找这个了,原来VS也可以makefile,在windows上解析makefile的软件叫NMAKE.exe 打算用命令Cmake -G“NMake Makefiles” 生成VS环境下Nmake的 ...

  7. VS2005环境下采用makefile编译、使用libjpeg.lib函数库

    1.从www.ijg.org下载源码,解压后得到文件夹jpeg-8d 2.在文件夹里新建jconfig.h文件,将jconfig.vc里的内容拷到jconfig.h中 3.编译. Run->CM ...

  8. libevent在windows下用visual studio编译时出现error C2894错误的原因与解决方法

    libevent是一个使用很广泛的网络库,今天想了解下它.于是去git clone了一份源码,用vs2005的命令行:nmake -f makefile.nmake编译之,顺利编译通过,生成三个静态库 ...

  9. 手动写Makefile编译Android NDK的so

    之所以摒弃NDK,是因为NDK编译出来的so太大,而且导出表总有一些没用的符号.而且手动编译的话,可以得到编译过程中间的.i和.s文件,可以删除一些没用的汇编代码.现在代码列出来:我的NDK C的代码 ...

随机推荐

  1. java面试记录一:跳表、判断二叉树相同、冒泡排序、cookie和session的区别、设计模式(单例、工厂、模板方法、原型、代理、策略)、抽象类与接口的区别

    1.什么是跳表? 跳表实际上就是多层链表 跳表可用在让链表的元素查询接近线性时间 代码结构及java实现参考博客园随笔 2.判断两棵二叉树是否相同?(结构相同,内容相同) 思路:(1)先定义树节点Tr ...

  2. 阿里云Linux服务器安装Redis 完整步骤(包括处理远程连接问题)

    跟随本篇文章步骤,包你成功安装并连接使用. 1.获取redis资源 wget http://download.redis.io/releases/redis-4.0.8.tar.gz 2.解压 tar ...

  3. 关于Django图片上传

    首先要设置settings # 上传文件 MEDIA_ROOT = 'media' # 项目下的目录 MEDIA_URL = "/media/" # 跟STATIC_URL类似,指 ...

  4. 文本harry potter的字符统计

    实现计算文件中字符的占比和不同单词的个数两项功能,首先将文本文件按行导入到程序中,再通过charAT()函数来实现对单个字符的操作,并用集合来统计字符总数以及不同的字符的个数,进而输出各个字符的个数以 ...

  5. Python-Django学习笔记(一)-MTV设计模式

    Django是开源的.大而且全的Web应用框架. 它独具特色,采用了MTV设计模式. MTV框架包括:Model(模型).Template(模板)和View(视图) Model(模型):负责业务对象与 ...

  6. Ecshop各个页面文件介绍,主要文件功能说明

    1.模板文件说明 style.css – 模板所使用样式表activity.dwt – 活动列表article.dwt – 文章内容页article_cat.dwt – 文章列表页article_pr ...

  7. JavaSwing开发简单的银行管理系统 附源码

    开发环境: Windows操作系统开发工具: MyEclipse/Eclipse+Jdk+mysql数据库 运行效果图:

  8. OpenGL 编程指南 (3.1)

    1.OpenGL使用的是RGB颜色空间,例如三个颜色分量各占8位,那么就说这个颜色值色深24,能够表示2^24中颜色. 2.多重采样是基于采样的抗锯齿技术,有OGAA(ordered grid ant ...

  9. 剑指offer 62. 二叉搜索树的第 k 个结点

    62. 二叉搜索树的第 k 个结点 题目描述 给定一棵二叉搜索树,请找出其中的第k小的结点.例如, (5,3,7,2,4,6,8)    中,按结点数值大小顺序第三小结点的值为4. 法一: 非递归中序 ...

  10. json_encode中文不转义问题

    //php5.3之后才有这个参数,这样存入数据库中的中文json数据就不会转义,也能被正确解析1JSON_UNESCAPED_UNICODE(中文不转为unicode ,对应的数字 256) JSON ...