使用nmake生成项目

一般开源软件下都有CMakeLists.txt文件,便于使用cmake生成解决方案。

但是今天在编译开源的libjpeg时,这个里面就没有CMakeLists.txt文件,所以不便于使用cmake。

要生成Visual Studio 解决方案的方法有:

方法一

自己建立一个Visual Studio空项目,然后将头文件和源文件都添加进去建立解决方案。

方法二

自己写CMakeLists.txt文件,然后使用cmake生成解决方案。

现在重点要说的是:

方法三

使用nmake生成解决方案。

从下面这里可以直接使用nmake。

然后

cd /d "libjpeg源码目录下"
libjpeg源码目录下包含文件 makefile.vc,以及一些以make*.v10文件
修改makefile.vc的第12行,主要是给win32.mak路径添加完整。
修改前:
 1 # Makefile for Independent JPEG Group's software
 2 
 3 # This makefile is for Microsoft Visual C++ on Windows NT (and 95?).
 4 # It builds the IJG library as a statically linkable library (.LIB),
 5 # and builds the sample applications as console-mode apps.
 6 # Thanks to Xingong Chang, Raymond Everly and others.
 7 
 8 # Read installation instructions before saying "nmake" !!
 9 # To build an optimized library without debug info, say "nmake nodebug=1".
10 
11 # Pull in standard variable definitions
12 !include <win32.mak>

修改后:

 1 # Makefile for Independent JPEG Group's software
 2 
 3 # This makefile is for Microsoft Visual C++ on Windows NT (and 95?).
 4 # It builds the IJG library as a statically linkable library (.LIB),
 5 # and builds the sample applications as console-mode apps.
 6 # Thanks to Xingong Chang, Raymond Everly and others.
 7 
 8 # Read installation instructions before saying "nmake" !!
 9 # To build an optimized library without debug info, say "nmake nodebug=1".
10 
11 # Pull in standard variable definitions
12 !include <C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\win32.mak>

修改完成后,在刚才的命令窗口执行:

>nmake /f makefile.vc setup-v10

这样就可以通过nmake生成Visual Studio的解决方案了。然后就可以通过visual Studio 2015打开 生成的解决方案。

关于nmake的工作原理,为生成解决方案,依赖 makefile.vc,以及一些以make*.v10文件,其中 *.v10文件对应的是生成Visual Studio 2010的解决方案的。

所以用Visual Studio 2015打开解决方案时会提示升级c++。

直接生成的解决方案是 32位的,想编译64位的库可以通过Configuration Manager 属性配置x64的解决方案。

猜你喜欢

转载自www.cnblogs.com/juluwangshier/p/12526861.html
今日推荐