redhat6版本編譯不少軟件都會語法檢查太嚴,致使編譯通不過。log4cxx就是其中之一,不過都是頭文件缺失引發的錯誤,補充頭文件便可,我把我安裝時碰到的問題寫出來,但願有人碰到相似的問題,不用走彎路,高手就飄過吧。apache
安裝log4cxx以前需檢查以下包是否安裝,socket
下載當前最新版本this
wget http://mirror.bjtu.edu.cn/apache/logging/log4cxx/0.10.0/apache-log4cxx-0.10.0.tar.gz server
解壓安裝get
./configure --prefix=/usr/server/log4xxinput
makestring
很快就能夠看到報錯,如圖console
'memmove' was not declared in this scope編譯
缺乏string.h這個頭文件,若是是低版本會自動補上來,修改src/main/include/log4cxx/helpers/inputstream.h添加以下stream
繼續make,不須要make clean之類的操做,再次報錯,內容以下。
'memcpy' was not declared in this scope
一樣,修改src/main/include/log4cxx/helpers/socketoutputstream.h添加#include<string.h>頭文件,不上圖了
繼續make,應該到以下報錯
console.cpp:58: error: ‘puts’ was not declared in this scope
console.cpp:63: error: ‘strcmp’ was not declared in this scope
console.cpp:66: error: ‘stderr’ was not declared in this scope
console.cpp:66: error: ‘stdout’ was not declared in this scope
console.cpp:66: error: ‘fputs’ was not declared in this scope
console.cpp:69: error: ‘stderr’ was not declared in this scope
console.cpp:69: error: ‘stdout’ was not declared in this scope
console.cpp:102: error: ‘stderr’ was not declared in this scope
console.cpp:102: error: ‘stdout’ was not declared in this scope
console.cpp:104: error: ‘stderr’ was not declared in this scope
console.cpp:104: error: ‘stdout’ was not declared in this scope
console.cpp:107: error: ‘stderr’ was not declared in this scope
console.cpp:107: error: ‘fputs’ was not declared in this scope
console.cpp:110: error: ‘fflush’ was not declared in this scope
修改src/examples/cpp/console.cpp,添加二行
若是不添加string.h後面還會有報錯(error: ‘strcmp’ was not declared in this scope)
修改完成後,再次make,就沒有問題了,最後再執行make install,就編譯安裝成功了。