標籤:style blog http color io os 使用 ar strong
本文一共包含了17個步驟,按照下面的步驟就可以完成vs2010中編譯log4cxx的工作了。
1. 下載 log4cxx 以及 apr 和 apr-util 源碼:
a) http://www.apache.org/dyn/closer.cgi/logging/log4cxx/0.10.0/apache-log4cxx-0.10.0.zip
b) http://archive.apache.org/dist/apr/apr-1.2.11-win32-src.zip
c) http://archive.apache.org/dist/apr/apr-util-1.2.10-win32-src.zip
2. 將 3 個壓縮包解壓到同一個目錄.如:
3. 將 apr-1.2.11 重新命名為 apr, 將 apr-util-1.2.10 重新命名為 apr-util.如:
4、開啟cmd視窗,如所示:
5、在4中輸入:cd D:\log4cxx_compile\apache-log4cxx-0.10.0 斷行符號
然後輸入:d: 斷行符號後 切換至 apache-log4cxx-0.10.0 目錄
6、在5中輸入:configure.bat 斷行符號
7. 在6的基礎下dos視窗下繼續輸入: configure-aprutil.bat 斷行符號
8、進入D:\log4cxx_compile\apr-util\include中並找到apu.hw檔案,如:
9、用Notepad++ 開啟apu.hw檔案(記事本也可以)
手動修改 apr-util\include\apu.hw 裡的內容
#define APU_HAVE_APR_ICONV 1
改為
#define APU_HAVE_APR_ICONV 0
10. 使用VS2010開啟 apache-log4cxx-0.10.0\projects 下的 log4cxx.dsw
開啟工程會提示轉換:
11、轉換好後工程如:
12、將 log4cxx 設定為啟動項.
設定前:
設定後:
13. 開始編譯.log4cxx
出現
4>D:\log4cxx_compile\apache-log4cxx-0.10.0\src\main\include\log4cxx/spi/loggingevent.h(155): error C2252: 只能在命名空間範圍內顯式執行個體化模板
a) 雙擊 "輸出" 視窗中的錯誤行, 此時會在 "代碼視窗" 中出現錯誤的位置.如:
b) 選擇 LOG4CXX_LIST_DEF, 按鍵盤 F12, 此時會跳轉到該宏的定義,如:
c) 將
#define LOG4CXX_LIST_DEF(N, T) \ template class LOG4CXX_EXPORT std::allocator<T>; \ template class LOG4CXX_EXPORT std::vector<T>; \ typedef std::vector<T> N
替換為: #define LOG4CXX_LIST_DEF(N, T) \ typedef std::vector<T> N
14、按照13修改後,重新編譯
出現
2>network_io\unix\multicast.c(137): error C2079: “mip”使用未定義的struct “group_source_req”錯誤
雙擊第一行出錯輸出, 將 136 和 148 行的 #if MCAST_JOIN_SOURCE_GROUP 注釋, 替換為 #if defined (group_source_req)
15、按照14修改後,重新編譯
出現
‘4>..\src\main\cpp\stringhelper.cpp(64): error C2039: “insert_iterator”: 不是“std”的成員‘ 等錯誤.
在該 .cpp 中(stringhelper.cpp) 加入標頭檔 #include<iterator>
16、按照15修改後,重新編譯
出現 ‘無法解析的外部符號 xxx‘ 等錯誤.
將 apr, aprutil, xml 添加至 log4cxx 的引用中.(按照下面4副圖的順序操作)
17. 選擇重建解決方案.
編譯成功後:
到此log4cxx編譯就完成了。
在vs2010中編譯log4cxx-0.10.0詳細方法(從下載、編譯、解決錯誤詳細介紹)(轉載)