作者:loleeve 日期:2004-10-10 e-mail:[email protected]
编译环境:Microsoft Visual C++ .NET 2003 (v7.0) eMule版本:0.44b
[1]下载源代码和支持库 1.下载eMule v0.44b 源代码 http://www.emule-project.com/ 2.Crypto++ v5.1 http://www.eskimo.com/~weidai/cryptlib.html 3.zlib v1.2.1 http://www.gzip.org/zlib/ 4.id3lib v3.8.3 http://sourceforge.net/projects/id3lib/ 5.libpng http://www.libpng.org/pub/png/libpng.html 或 http://sourceforge.net/projects/libpng/ 6.ResizableLib 1.3 http://sourceforge.net/projects/resizablelib/
[2]编译eMule所需要的库。 注意:编译的所有库工程的Run-Time Libaray都统一用用Multi-threaded (/MT)
1.Crypto++ v5.1 对于VC++.NET 2003编译器,我们要对源代码做以下修改:
在文件integer.cpp中把 AllocatorBase<T>::pointer AlignedAllocator<T>::allocate(size_type n, const void *) 改为 CPP_TYPENAME AllocatorBase<T>::pointer AlignedAllocator<T>::allocate(size_type n, const void *)
在文件pubkey.h中把 template <class PK, class GP> class DL_KeyImpl : public PK { public: typedef GP GroupParameters; OID GetAlgorithmID() const {return GetGroupParameters().GetAlgorithmID();} 改为 template <class PK, class GP, class O = OID> class DL_KeyImpl : public PK { public: typedef GP GroupParameters; O GetAlgorithmID() const {return GetGroupParameters().GetAlgorithmID();} 然后编译Release版本,把生成的cryptlib.lib和头文件放到eMule下的crypto51。
2.ResizableLib 1.3 编译成Release Static版本,把ResizableLib.lib和头文件拷到eMule下的ResizableLib。
3.zlib v1.2.1 首先,打开zlib\Makefile.msc文件,把 CFLAGS = -nologo -MD -O2 $(LOC) 改为 CFLAGS = -nologo -MT -O2 $(LOC) 统一使用/MT 运行时库。 然后,在zlib\下运行nmake /a /f win32\Makefile.msc。(运行nmake前先运行VS.NET2003下vc7\bin\vcvars32.bat注册编译环境变量),把生成的zlib.lib和头文件放到eMule下的zlib。
4.libpng 进入png\projects\visualc6打开libpng工程,在libpng工程里添加之前生成的zlib头文件和库文件路径,编译成LIB ASM Release,然后把libpng.lib改名为png.lib,包括头文件一起拷到eMule下的png。
5.id3lib v3.8.3 解压id3lib v3.8.3,把config.h.win32改为config.h,然后进入解压后目录下的libprj并打开工程文件,去掉id3lib v3.8.3自带zlib库的头文件路径,添加之前编译好zlib库的头文件路径,编译Release版本。把生成的id3lib.lib和头文件拷到eMule下的id3。
6.CxImage 进入eMule\CxImage,打开工程文件,设置正确的png和zlib的库文件和头文件路径,然后编译Release版本,把生成的CxImage.lib拷到eMule\CxImage下。
[3]编译eMule 打开DialogMinTrayBtn.cpp把下面的 #if 0 // define this to use that source file as template #define TEMPLATE template <class BASE> #else // define this to instantiate functions for class 'BASE' right in this CPP module #define TEMPLATE #define BASE CResizableDialog #endif 改为 #if 0 // define this to use that source file as template #define TEMPLATE template <class BASE> #else // define this to instantiate functions for class 'BASE' right in this CPP module #define TEMPLATE template <> #define BASE CResizableDialog #endif 检查一下所需要的头文件目录和库文件是否正确,然后就可以编译Release版本的eMule了。如果所有eMule的支持库都用/MT编译的话,应该链接不会出什么问题,如果还是出现运行时库符号冲突,可以在链接参数里忽略某些运行时库。
官方的eMule编译通过了,接下来我们可以干嘛呢?如果你是牛人,又觉得现在的eMule不合自己口味,那你大可以修改它,但是如果你想发布你自己的eMule版本,别忘了把源代码也一起发布喔,因为eMule是受到GNU保护的。有点废话了,牛人又怎么会看这篇文章啦~~~~哈哈~~eMule的代码确实写得很优秀,是一个难得的学习机会。

|