Windows 下編譯log4cxx (x64)

來源:互聯網
上載者:User
1. 編譯環境
windows 10 x64, vs2017
2. 下載依賴apr, apr-iconv. apr-util

建立目錄如下:
C:/work
 |_ apr
 |_ apr-iconv
 |_ apr-util
 |_ log4cxx(名稱任意)

可以直接下載安裝包,也可以使用svn檢出項目,SVN檢出地址http://apr.apache.org/anonsvn.html

注意:檔案夾名稱必須叫:apr,apr-iconv,apr-util
注意:apr和apr-util檢出為1.5.x版本,1.6.x 缺少檔案
+ SVN檢出地址:
- apr: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x/
- apr-iconv:  http://svn.apache.org/repos/asf/apr/apr-iconv/trunk/
- apr-util:  http://svn.apache.org/repos/asf/apr/apr-util/branches/1.5.x/
- log4cxx 下載地址:https://mirrors.tuna.tsinghua.edu.cn/apache/logging/log4cxx/0.10.0/apache-log4cxx-0.10.0.zip 3. 下載Sed

下載目錄:http://gnuwin32.sourceforge.net/packages/sed.htm下載sed的windows版本(二進位程式,以及啟動並執行依賴dll) 並將 sed添加到系統內容變數

sed-4.2.1-bin.zip
sed-4.2.1-dep.zip 4. 在log4cxx目錄下執行 configure.bat, configure-aprutil.bat 5. 使用vs開啟 log4cxx\projects\log4cxx.dsw 6. 菜單“產生”-> “組態管理員” 將debug和release都調整為64位 7. 菜單“項目” -> “重定解決方案目標” ,4個項目依次執行,並將log4cxx設為啟動項目 8. 編譯

剛開始編譯會出現類似於以下的錯誤:

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

如果報如下錯誤:
C2039 “insert_iterator”: 不是“std”的成員

解決辦法:
在源檔案頭部添加:#include

備忘:不建議使用log4cxx(編譯太麻煩),建議使用spdlog

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.