版權(quán)聲明
:轉(zhuǎn)載時請以超鏈接形式標(biāo)明文章原始出處和作者信息及本聲明
http://jiangliwei.blogbus.com/logs/28509863.html
代碼來源:
官方eMule-VeryCD源碼包
http://download.verycd.com/eMule-VeryCD-src.rar
編譯好的第三方庫,來http://www.verycd.com/groups/eMuleDev/209863.topic
http://download.VeryCD.com/emule071112_libsForVS2005.rar
編譯環(huán)境:WindowsXPsp3CN
VC2008EN + SP1
ATL Server??????? ????????http://www.codeplex.com/AtlServer
修改過程:(只修改error的部分,警告看著不爽自己整)
1. 解壓縮源碼包,其中src目錄下為emule源碼。
2. vs2008打開emule.sln,首先是轉(zhuǎn)換工程向?qū)ВD(zhuǎn)換之。
3. 首次build,會提示你如下錯誤。
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\..\src\mfc\afximpl.h(631) : error C2059: syntax error : '<L_TYPE_raw>'
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\..\src\mfc\afximpl.h(631) : error C2238: unexpected token(s) preceding ';'
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\..\src\mfc\afximpl.h(635) : error C2059: syntax error : '<L_TYPE_raw>'
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\..\src\mfc\afximpl.h(635) : error C2238: unexpected token(s) preceding ';'這個錯誤是由于WINVER定義不正確造成的,編輯stdafx.h,更改代碼如下:
#ifndef WINVER
#define WINVER 0x0501
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
4. 重新build,又會有一大坨error,其中最多的是
error C2011: 'tagMENUINFO' : 'struct' type redefinition結(jié)構(gòu)重復(fù)定義,查看winuser.h就會發(fā)現(xiàn)如下定義
#if(WINVER >= 0x0500)
...
typedef struct tagMENUINFO
{
DWORD cbSize;
DWORD fMask;
DWORD dwStyle;
UINT cyMax;
HBRUSH hbrBack;
DWORD dwContextHelpID;
ULONG_PTR dwMenuData;
} MENUINFO, FAR *LPMENUINFO;
typedef MENUINFO CONST FAR *LPCMENUINFO;
還是WINVER的問題,編輯TitleMenu.h,更改代碼如下:
#if (WINVER < 0x0500)
typedef struct tagMENUINFO
{
DWORD cbSize;
DWORD fMask;
DWORD dwStyle;
UINT cyMax;
HBRUSH hbrBack;
DWORD dwContextHelpID;
ULONG_PTR dwMenuData;
} MENUINFO, FAR *LPMENUINFO;
typedef MENUINFO CONST FAR *LPCMENUINFO;
#endif
或者直接注釋掉也可以
5. 重新build(很可能你改完了上面的代碼后,上一次build仍沒有結(jié)束,要毫不猶豫地cancel),再次出現(xiàn)一大坨error,總共有兩類()
1>.\UPnpNat.cpp(706) : error C2440: '=' : cannot convert from 'const char *' to 'char *'
1>.\SharedFilesCtrl.cpp(585) : error C2039: 'bWin95' : is not a member of 'AUX_DATA'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\..\src\mfc\afximpl.h(54) : see declaration of 'AUX_DATA'
1>SearchListCtrl.cpp
1>.\SearchListCtrl.cpp(1729) : error C2039: 'bWin95' : is not a member of 'AUX_DATA'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\..\src\mfc\afximpl.h(54) : see declaration of 'AUX_DATA'其中第一個很好改,強制轉(zhuǎn)換類型即可。
至于第二種錯誤,AUX_DATA中已不再包含成員bWin95,如有需要參與運算的部分則bWin95=0,具體請自行g(shù)oogle。
這個改起來也很容易,將所有bWin95的部分注釋掉即可,其多半是參與if判斷,需要的地方統(tǒng)統(tǒng)取FALSE即可。涉及到的文件共有14個
修改舉例lf.lfQuality = afxData.bWin95 ? NONANTIALIASED_QUALITY : ANTIALIASED_QUALITY;
改為
lf.lfQuality = ANTIALIASED_QUALITY;
if (!afxData.bWin95 && iItem >= 0)
改為
if (iItem >= 0)
6. 改好之后再次build,出現(xiàn)4條error
>.\EncryptedStreamSocket.cpp(361) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\EncryptedStreamSocket.cpp(492) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\EncryptedStreamSocket.cpp(590) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\Emule.cpp(314) : fatal error C1189: #error : "You are using an MFC version which may require a special version of the above function!"前三條純粹是寫法不正確,變量前面竟然沒有寫類型,為之一一補充上即可。
第二種是宏警告,意思是VS版本不正確之類的。在其前面的條件中補充上
|| _MFC_VER==0x0900
即可,總共有2處
7. 再次build,這次出現(xiàn)的錯誤算是比較常見的,不再列舉
去掉stdafx.h里的以下幾行
#ifndef _USE_32BIT_TIME_T
#define _USE_32BIT_TIME_T
#endif
8. build, 提示link錯誤
ResizableLib.lib(ResizableDialog.obj) : error LNK2019: unresolved external symbol "public: class CMenu * __thiscall CWnd::GetMenu(void)const " (?GetMenu@CWnd@@QBEPAVCMenu@@XZ) referenced in function "protected: int __thiscall CResizableDialog::OnCreate(struct tagCREATESTRUCTW *)" (?OnCreate@CResizableDialog@@IAEHPAUtagCREATESTRUCTW@@@Z)
ResizableLib.lib(ResizableSheet.obj) : error LNK2001: unresolved external symbol "public: class CMenu * __thiscall CWnd::GetMenu(void)const " (?GetMenu@CWnd@@QBEPAVCMenu@@XZ)
ResizableLib.lib(ResizableSheet.obj) : error LNK2019: unresolved external symbol "public: long __thiscall CWnd::SendMessageW(unsigned int,unsigned int,long)" (?SendMessageW@CWnd@@QAEJIIJ@Z) referenced in function "public: void __thiscall CResizableSheet::RefreshLayout(void)" (?RefreshLayout@CResizableSheet@@QAEXXZ)這里說明一下,emule的源碼目錄中,其他幾個像ResizableLib,crypto51是其所依賴的第三方庫,跟emule工程一樣需要重新轉(zhuǎn)換并編譯。但是為了省事起見,這里直接使用了他人編譯好的lib庫(在前面有說明)。但是盡管如此,有一部分還是需要重新編譯一下的。
需要重新轉(zhuǎn)換并編譯ResizableLib這個工程,然后在工程屬性里面將Debug和Release的”Chartacter Set“設(shè)置為“Use Unicode Character Set”,rebuild之后將生成的ResizableLib.lib分別copy至DebugUnicode和ReleaseUnicode目錄(修改工程屬性直接生成到這兩個目錄里也是一樣的)。
再次編譯emule工程即可通過。
另外需補充一點,VS2008如果沒裝sp1補丁有一個地方遍不過去,因為懶得查,我就忽略了。
再有,VS2008默認(rèn)安裝時沒有包括ATLServer庫(現(xiàn)在已開源)的,需要去官方下載,解壓后制定inc的路徑即可。
至此大功告成,其余的部分請自行研究吧。我也是剛剛開始看emule的源碼,因為遍不過去無法調(diào)試,很不爽,所以多花了點時間研究一下,如果有什么不正確或需要補充的地方請與我聯(lián)系。