使用Visual Studio编译7z源码

两种方式,一种命令行使用nmake,一种通过visual studio。

0x01 源码下载

http://www.7-zip.org/download.html

使用Visual Studio编译7z源码_第1张图片

0x02 makefile修改

%7z_source%\CPP\Build.mak文件第34行附近,找到LFLAGS = $(LFLAGS) -OPT:NOWIN98,删除-OPT:NOWIN98选项

此处不修改,后面nmake会报错,根据提示信息找到对应文件删除该选项也可以。

参考页面:http://www.ski-epic.com/2012_compiling_7zip_on_windows_with_visual_studio_10/index.html


0x03 编译

vs命令提示符工具,cd到%7z_source%\CPP\7zip目录,执行

nmake NEW_COMPILER=1 MY_STATIC_LINK=1

等待编译结束即可。


0x04 Visual Studio编译

使用VS打开%7z_source%\CPP\7zip\Bundles\Format7zF\Format7z.dsw

在7zCrcOpt.asm和AesOpt.asm两个文件上右键属性,修改其配置信息,如图

参考页面:

http://stackoverflow.com/questions/12387701/error-lnk1104-obj-file-without-any-file-name

http://blog.csdn.net/butwang/article/details/6164933


0x05 Build

使用Visual Studio编译7z源码_第2张图片

0x06 Help

关于7z源代码文件结构说明

[Bundle]
Alone         7za.exe: Standalone version of 7z
Alone7z       7zr.exe: Standalone version of 7z that supports only 7z/LZMA/BCJ/BCJ2
SFXCon        7zCon.sfx: Console 7z SFX module
SFXWin        7z.sfx: Windows 7z SFX module
SFXSetup      7zS.sfx: Windows 7z SFX module for Installers
Format7z            7za.dll:  .7z support
Format7zExtract     7zxa.dll: .7z support, extracting only
Format7zR           7zr.dll:  .7z support, LZMA/BCJ* only
Format7zExtractR    7zxr.dll: .7z support, LZMA/BCJ* only, extracting only
Format7zF           7z.dll:   all formats

[UI]
Agent         Intermediary modules for FAR plugin and Explorer plugin
Console       7z.exe Console version
Explorer      Explorer plugin
Resource      Resources
Far           FAR plugin
Client7z      Test application for 7za.dll

[Compress]
BZip2        BZip2 compressor
Branch       Branch converter
ByteSwap     Byte Swap converter
Copy         Copy coder
Deflate
Implode
Arj
LZMA
PPMd          Dmitry Shkarin's PPMdH with small changes.
LZ            Lempel - Ziv

[Crypto]
7zAES         Cipher for 7z
AES           AES Cipher
Rar20         Cipher for Rar 2.0
RarAES        Cipher for Rar 3.0
Zip           Cipher for Zip

由于原始7z sdk调用不太友好,所以,我在开源项目的基础上,又重新进行了封装,代码已经开源https://github.com/defhook/SevenZip

你可能感兴趣的:(c/c++)