vs2010 編譯 log4cxx 0.10.0


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

image

 

2. 將 3 個壓縮包解壓到同一個目錄.

image

 

3. 將 apr-1.2.11 重命名為 apr, 將 apr-util-1.2.10 重命名為 apr-util.

image

最終如下:

image

 

4. 使用 cmd, 切換至 apache-log4cxx-0.10.0 目錄, 運行 configure.bat

image

 

5. 在與第 4  步同一目錄下的 cmd 中, 執行 configure-aprutil.bat

1) 此時, 如果環境變量中沒有 sed 程序, 則會出現:

image

此時應該:

手動修改 apr-util\include\apu.hw 里的內容

#define APU_HAVE_APR_ICONV 1

改為

#define APU_HAVE_APR_ICONV 0

2) 如果系統可以找到 sed 程序, 那么會出現:

image

 

6. 打開 apache-log4cxx-0.10.0\projects 下的 log4cxx.dsw

image

打開工程會提示轉換:

image

 

7. 將 log4cxx 設置為啟動項.

image

 

8. 開始編譯. 快捷鍵 F7.

image

 

9.

1) 出現

'4>D:\log4cxx-src\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

image

 

2) 出現

'2>network_io\unix\multicast.c(137): error C2079: “mip”使用未定義的 struct“group_source_req"' 等錯誤.

image

雙擊第一行出錯輸出, 將 136 和 148 行的 #if MCAST_JOIN_SOURCE_GROUP 注釋, 替換為 #if defined (group_source_req)

 

image

 

3) 出現

'4>..\src\main\cpp\stringhelper.cpp(64): error C2039: “insert_iterator”: 不是“std”的成員' 等錯誤.

image

在該 .cpp 中(stringhelper.cpp) 加入頭文件 <iterator>:

image

 

4) 出現

'無法解析的外部符號 xxx' 等錯誤.

image

將 apr, aprutil, xml 添加至 log4cxx 的引用中.

image

 

10. 選擇重新生成解決方案. 否則可能會造成 '無法打開 apr_iconv.h' 錯誤. 個人懷疑是第 5 步中, configure-aprutil.bat 腳本中的 sed 命令沒有正確更新文件的時間所致.

image

編譯成功后:

image

 

reference:

http://cn.waterlin.org/cpp/log4cxx.html

http://blog.csdn.net/rabbit729/article/details/2772179

http://blog.csdn.net/kungbx/article/details/6129564

http://hi.baidu.com/gaocher/blog/item/8f17e92729a56c7635a80ff2.html

http://blog.csdn.net/everettjf/article/details/6194933

http://hi.baidu.com/antbean1988/blog/item/40b2531cf8d271d3c3fd7898.html

http://hi.baidu.com/antbean1988/blog/item/40b2531cf8d271d3c3fd7898.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM