今天在本地看到一个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. 从0开始学算法--排序(1.12c++利用标准库排序)

    1,简单数组按升序排序 sort(a,a+n); #include <algorithm> #include <iostream> #include <cstring&g ...

  2. dataTables插件的使用

    用到dataTables这个插件还是因为Metronic这个框架里有用到,不然我不会选择它的,为啥呢?就感觉它的文档有点复杂(当然,也有我智商不够用的原因):既然用了,那就说说我遇到的问题吧,以防下次 ...

  3. [Note]prufer

    [Note]Prufer编码 实现 不断删除度数为\(1\)的最小序号的点,并输出与其相连的节点的序号,直至树中只有两个节点. 性质 任何一棵\(n\)节点的树都可以唯一的用长度为\(n-2\)的pr ...

  4. 添加右键新增.md文件

    Windows下设置.md文件右键可新建 应用场景:Windows10, Typora(Markdown编辑器) 因为习惯用Markdown来写文档, 所以常常需要新建.md文档,但由于Windows ...

  5. numpy 生成数组

    可以看这个博客 https://www.cnblogs.com/td15980891505/p/6082858.html import numpy as np 建立数组并初始化数组 np.zeros( ...

  6. Python读取execl表格

    读取execl表格 import xlrd Execl = xlrd.open_workbook(r'Z:\Python学习\python26期视频\day76(allure参数.读excel.发邮件 ...

  7. 2019牛客多校第五场 F maximum clique 1 状压dp+最大独立集

    maximum clique 1 题意 给出一个集合s,求每个子集的最大独立集的权值和(权值是独立集的点个数) 分析 n比较小,一股浓浓的暴力枚举每一个子集的感觉,但是暴力枚举模拟肯定会T,那么想一想 ...

  8. Supervision meeting notes 2019/11/29

    topic 分支:  1. subgraph/subsequence mining Wang Jin, routine behavior/ motif. Philippe Fournier Viger ...

  9. Spring Cloud介绍

    Spring Cloud中国社区博客 Spring Cloud发展到2016年,国内关注的人越来越多,但是相应学习交流的平台和材料比较分散,不利于学习交流,因此Spring Cloud中国社区应运而生 ...

  10. Form表单利用Jquery Validate验证以及ajax提交

    #表单利用Jquery验证验证以及ajax提交 概述>详细讲解表单利用Jquery >验证验证以及ajax提交的过程,以及Validate的自定义提示语,非空判断,输入字段的远程ajax验 ...