日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

编译电驴v1.1.15 with vs2010

發布時間:2024/3/12 编程问答 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 编译电驴v1.1.15 with vs2010 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

//使用的系統是win7 32位英文版,VS2010-sp1英文版。電驢的代碼大概是10年10月份下載的。

本作者使用的 ?win 32位中文字版 vs2010 ? ? ? ? ? ? ? 電驢代碼是 ?2011.5.28 日在電驢官網下載

首先編譯所要用的庫。

1.?error C2440: 'initializing' : cannot convert from 'int' to 'const unsigned char *'。

錯誤在文件utility(163)中,這個是編譯環境提供的文件。這種錯誤一般是由模板實例化所引起的參數不匹配造成,因該在后面的錯誤中改正。

錯誤定位在下面這條語句:

return HashIdentifier(NULL, 0);

引起錯誤的原因是在map中引入了c++ 0x的新特性,右值引用,而導致的參數演繹后類型不匹配。

修改:

return HashIdentifier((byte*)NULL,(unsigned int) 0);?

為啥要這樣強制轉換是因為下面

typedef std::pair<const byte *, unsigned int> HashIdentifier;

(查了一下,最新版的cryplib庫可以在Vs2010中編譯通過,解決問題的方法和上面的一樣)

2.??error C2664: 'CryptoPP::AllocatorWithCleanup<T>::AllocatorWithCleanup(const CryptoPP::AllocatorWithCleanup<T> &)' : cannot convert parameter 1 from 'CryptoPP::AllocatorWithCleanup<T>' to 'const CryptoPP::AllocatorWithCleanup<T> &'

這個是由于secblock.h缺少一個類型轉換構造函數引起的。查閱了cryptlib的最新版本,發現增加了很多東西。其中有下面語句:

?? ?template <class U> struct rebind { typedef AllocatorWithCleanup<U, T_Align16> other; };

#if?_MSC_VER >= 1500 ?//表示編譯器版本大于或等于1500

AllocatorWithCleanup() {}

template <class U, bool A> AllocatorWithCleanup(const AllocatorWithCleanup<U, A> &) {}

#endif

上面進行了CryptoPP::AllocatorWithCleanup<CryptoPP::HuffmanDecoder::CodeInfo,0>?

CryptoPP::AllocatorWithCleanup<std::_Container_proxy,0>

的類型轉換。

修改:

在secbolck.h的103行(template <class U> struct rebind { typedef AllocatorWithCleanup<U> other; };)下面增加如下內容:

#if _MSC_VER >= 1500

AllocatorWithCleanup() {}

template <class U, bool A> AllocatorWithCleanup(const AllocatorWithCleanup<U, A> &) {}

#endif

編譯。。。

暈,還是不行,看看這次的錯誤,意思是說給AllocatorWithCleanup模板的參數太多了,比較了一下,確實,新版的cryptlib庫中,這個模板有兩個參數,舊版的就一個。于是將上面的A參數去掉:變為

?

#if _MSC_VER >= 1500//加在AllocatorWithCleanup 類定義里面 AllocatorWithCleanup() {} template <class U> AllocatorWithCleanup(const AllocatorWithCleanup<U> &) {} //template <class U, bool A> AllocatorWithCleanup(const AllocatorWithCleanup<U, A> &) {} #endif?

?

?

ok。

3.?接下來的錯誤來自兩個資源庫。其實這個錯誤很簡單,就是特別難找。錯誤的提示大概如下:

1>I:/Program Files/MSBuild/Microsoft.Cpp/v4.0/Microsoft.CppCommon.targets(113,5): error MSB3073:?The command "if not exist ../debug/lang md ../debug/lang

1>I:/Program Files/MSBuild/Microsoft.Cpp/v4.0/Microsoft.CppCommon.targets(113,5): error MSB3073: copy "E:/My Documents/easyMule-VeryCD-src--win7/src/lang/dynamic/languages - Chinese (Taiwan).dll" ../debug/lang/languages - Chinese (Taiwan).dll

1>I:/Program Files/MSBuild/Microsoft.Cpp/v4.0/Microsoft.CppCommon.targets(113,5): error MSB3073:?

1>I:/Program Files/MSBuild/Microsoft.Cpp/v4.0/Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 1.

經過堅持不懈的搜索搜索在搜索,還是沒找到,最后無意中在工程屬性頁中發現了這個:(如下圖)

看到了沒,那個if not啥啥啥的。這個動作實在build之后的事件,而出錯的原因就是,鏈接器成功創建了文件,但是現在卻找不到了。這個問題我在另一篇日志里講過,解決方法是將下圖中紅框中的內容改成zh_TW(如果是大陸語言,則是zh_CH,注意不能在這加后綴dll,不然還是同樣的錯誤):

到現在,lib庫編譯都沒有問題了,不過有個小問題,我始終沒找到解決方法。這個問題是這樣,就算我不改動代碼,每次build(注意,不是rebuild)的時候,都有下列輸出:

1>------ Build started: Project: id3lib, Configuration: Debug Win32 ------

2>------ Build started: Project: cryptlib, Configuration: Debug Win32 ------

1>Build started 2011/4/6 21:24:05.

2>Build started 2011/4/6 21:24:05.

2>InitializeBuildStatus:

2> ?Creating "./Debug/cryptlib.unsuccessfulbuild" because "AlwaysCreate" was specified.

1>InitializeBuildStatus:

1> ?Creating "./Debug/id3lib.unsuccessfulbuild" because "AlwaysCreate" was specified.

1>ClCompile:

2>CustomBuild:

2> ?Performing Custom Build Tools

1> ?All outputs are up-to-date.

1>I:/Program Files/MSBuild/Microsoft.Cpp/v4.0/Microsoft.CppBuild.targets(1151,5): warning MSB8012: TargetPath(E:/My Documents/easyMule-VeryCD-src--win7/id3lib/libprj/./Debug/id3lib.lib) does not match the Library's OutputFile property value (E:/My Documents/easyMule-VeryCD-src--win7/id3lib/libprj/id3libD.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).

1>I:/Program Files/MSBuild/Microsoft.Cpp/v4.0/Microsoft.CppBuild.targets(1153,5): warning MSB8012: TargetName(id3lib) does not match the Library's OutputFile property value (id3libD). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).

1>Lib:

1> ?All outputs are up-to-date.

1> ?id3lib_2005.vcxproj -> E:/My Documents/easyMule-VeryCD-src--win7/id3lib/libprj/./Debug/id3lib.lib

2>ClCompile:

2> ?All outputs are up-to-date.

1>BscMake:

1> ?All outputs are up-to-date.

1>FinalizeBuildStatus:

1> ?Deleting file "./Debug/id3lib.unsuccessfulbuild".

1> ?Touching "./Debug/id3lib.lastbuildstate".

1>

1>Build succeeded.

1>

1>Time Elapsed 00:00:00.24

2> ?All outputs are up-to-date.

2> ?All outputs are up-to-date.

2>Lib:

2> ?All outputs are up-to-date.

2> ?cryptlib_2005.vcxproj -> E:/My Documents/easyMule-VeryCD-src--win7/crypto51/crypto/./Debug/cryptlib.lib

2>FinalizeBuildStatus:

2> ?Deleting file "./Debug/cryptlib.unsuccessfulbuild".

2> ?Touching "./Debug/cryptlib.lastbuildstate".

2>

2>Build succeeded.

2>

2>Time Elapsed 00:00:00.27

========== Build: 2 succeeded, 0 failed, 9 up-to-date, 0 skipped ==========

有9個庫是沒有問題的,但是上面兩個始終重新編譯,這樣會造成編譯時間延長。。。很不爽啊。

下面就該編譯電驢的代碼了。這塊我碰到2個錯誤,一個是編譯時,一個在鏈接時。

1.?第一個錯誤是說:

1>WorkLayer/UPnP/UPnpMgr.cpp(500): error C2662: 'CUPnpNatMappingKey::Serialize' : cannot convert 'this' pointer from 'const CUPnpNatMappingKey' to 'CUPnpNatMappingKey &'

1> ? ? ? ? ?Conversion loses qualifiers

引發這條錯誤的代碼是: it -> Serialize(ar); 這個錯誤說的意思是,沒法將常量轉換成變量。原因在于set這個容器,set的begin函數在不同的標準庫中返回值的類型有一點小區別。有的實現返回const迭代器,而有的返回可修改迭代器。不幸的是,VS2010的stl中,set的begin總是返回的常量迭代器。 根據函數語義,修改如下:
for (it = m_setAddedMapping.begin(); it != m_setAddedMapping.end(); it++) { CUPnpNatMappingKey key(*it); key.Serialize(ar); } ar.Close(); ? ? 也就是增加了一個臨時變量,讓這個可修改的變量來調用Serialize。 2. 第二個問題的錯誤如下: uafxcwd.lib(afxglobals.obj) error LNK2005: "public: virtual __thiscall CMemDC::~CMemDC(void)" (??1CMemDC@@UAE@XZ) already defined in ProgressCtrlX.obj 上面是意思是,連接器說,我找到了兩個定義,一個在 uafxcwd.lib(afxglobals.obj)里面,還有一個在ProgressCtrlX.obj 。 找了一下,電驢里包含一個MemDC.h文件,里面定義了一個CMemDC類,不巧的是,VS2010的MFC新增了這個類,所以鏈接時會出問題。 那怎么解決了?有如下辦法: 1 修改MFC中CMemDC的名字。這個明顯不行。。。 2 將emule中的CMemDC改個名字,這個方法可以,可是我找了下,貌似用這個類的文件還不少。不甘心一條條改,于是想出下面的方法。。。 3 增加一個宏定義, #define CMemDC XCMemDC 將上面的語句加到stdafx.h的最后。(也可以在工程屬性頁中以編譯器指令的形式定義宏,格式為 /D "CMemDC=XCMemDC")。 經過5天斷斷續續的找啊改啊,驢子終于跑起來了,至于干不干活就在說吧,哈哈,睡覺! ps://本人發現的編譯問題
  • 在編譯lib的時候 對于語言包編譯是沒法解決的。使用他的 zh_CH 刪除后續.dll 或者不刪除都沒法解決,最后解決辦法手動將debug下面的zh_CH.dll 移動到
  • 在Pinger.h文件里面發現 類型重定義 解決辦法修改為#ifndef HAVE_WIN7_SDK_H typedef struct ip_option_information {u_char Ttl; /* Time To Live (used for traceroute) */u_char Tos; /* Type Of Service (usually 0) */u_char Flags; /* IP header flags (usually 0) */u_char OptionsSize; /* Size of options data (usually 0, max 40) */u_char FAR *OptionsData; /* Options data buffer */ } IPINFO, *PIPINFO, FAR *LPIPINFO; /* Note 1: The Reply Buffer will have an array of ICMP_ECHO_REPLY * structures, followed by options and the data in ICMP echo reply * datagram received. You must have room for at least one ICMP * echo reply structure, plus 8 bytes for an ICMP header. */ typedef struct icmp_echo_reply {u_long Address; /* source address */u_long Status; /* IP status value (see below) */u_long RTTime; /* Round Trip Time in milliseconds */u_short DataSize; /* reply data size */u_short Reserved; /* */void FAR *Data; /* reply data buffer */struct ip_option_information Options; /* reply options */ } ICMPECHO, *PICMPECHO, FAR *LPICMPECHO; #else typedef ip_option_information FAR *LPIPINFO; typedef ip_option_information IPINFO; #endif?
  • 找不到頭文件 WorkLayer/otherfunctions.cpp(26): fatal error C1083: 無法打開包括文件:“atlrx.h”: No such file or directory ?解決辦法? 在電驢討論網找到?VS 2008(我的是vs2010)中由于將ALT項目的部分代碼剝離出去成為了獨立的開源項目,需要用到ALT中正則表達式等功能就需要手動下載。
    參考:http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306398
    下載地址:http://www.codeplex.com/AtlServer?(http://www.codeplex.com/AtlServer)
    把下載的東西解壓縮到一個目錄,比如c:/alt/
    在VS里面[工具]--[選項]--[項目和解決方案]--[VC++目錄],在右上角選擇[包含引用的文件]中加入c:/alt/include就OK了
  • 總結

    以上是生活随笔為你收集整理的编译电驴v1.1.15 with vs2010的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。