早期版本的TrueCrypt若要编译成功,的确需要做多项微调,但是对于7.0a版本的代码,只需按照如下流程,即可在WinXP 32位系统下成功编译。
代码的ReadMe.txt是这么写的:
I. Windows
==========Requirements for Building TrueCrypt for Windows:
------------------------------------------------- Microsoft Visual C++ 2008 SP1 (Professional Edition or compatible)
- Microsoft Visual C++ 1.52 (available from MSDN Subscriber Downloads)
- Microsoft Windows SDK for Windows 7 (configured for Visual C++)
- Microsoft Windows Driver Kit 7.1.0 (build 7600.16385.1)
- RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki) 2.20
header files (available at ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20)
- NASM assembler 2.08 or compatible
- gzip compressorIMPORTANT:
The 64-bit editions of Windows Vista and later versions of Windows, and in
some cases (e.g. playback of HD DVD content) also the 32-bit editions, do not
allow the TrueCrypt driver to run without an appropriate digital signature.
Therefore, all .sys files in official TrueCrypt binary packages are digitally
signed with the digital certificate of the TrueCrypt Foundation, which was
issued by a certification authority. At the end of each official .exe and
.sys file, there are embedded digital signatures and all related certificates
(i.e. all certificates in the relevant certification chain, such as the
certification authority certificates, CA-MS cross-certificate, and the
TrueCrypt Foundation certificate). Keep this in mind if you compile TrueCrypt
and compare your binaries with the official binaries. If your binaries are
unsigned, the sizes of the official binaries will usually be approximately
10 KB greater than sizes of your binaries (there may be further differences
if you use a different version of the compiler, or if you install a different
or no service pack for Visual Studio, or different hotfixes for it, or if you
use different versions of the required SDKs).Instructions for Building TrueCrypt for Windows:
------------------------------------------------1) Create an environment variable 'MSVC16_ROOT' pointing to the installation
directory of MS Visual C++ 1.52.2) If you have installed the Windows Driver Development Kit in another
directory than '%SYSTEMDRIVE%\WinDDK', create an environment variable
'WINDDK_ROOT' pointing to the DDK installation directory.3) Copy the PKCS #11 header files to a standard include path or create an
environment variable 'PKCS11_INC' pointing to the directory where
the PKCS #11 header files are installed.4) Open the 'TrueCrypt.sln' solution in Microsoft Visual Studio 2008.
5) Select 'All' as the active solution configuration.
6) Build the solution.
7) If successful, there should be newly built TrueCrypt binaries in the
'Release' folder.
按照流程,环境配置如下:
代码编译也需要微调:
代码放置目录不要有中文或空格。
使用 VS2008 打开 TrueCrypt.sln,配置选择ALL,开始生成解决方案吧。
不出意外的话,会报一个错如下:
6>.\Setup.c(135) : error C2065: “PKEY_AppUserModel_ID”: 未声明的标识符
解决方案是在Setup.h中加入如下代码
#include "wtypes.h" const PROPERTYKEY PKEY_AppUserModel_ID = { { (unsigned long)2009,/*unsigned long Data1;*/ (unsigned short)12,/*unsigned short Data2;*/ (unsigned short)23,/*unsigned short Data3;*/ 0x44,0x55,0x55,0x55,0x55,0x55,0x55,0x55 },/* GUID */ (DWORD)PID_FIRST_USABLE /* pid */ };
再次生成,就OK了,东西都在 \Release\Setup Files\下。
参考:
除了上述配置之外,可能编译时会遇到 nasm 无法识别的问题,解决方案是将其拷入 "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" 目录下,这样就一切OK了。