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,就编译安装成功了。