- 下载解压
log4cxx下载地址:http://logging.apache.org/log4cxx/
apr-util、apr下载地址:http://apr.apache.org/download.cgi
解压
$tar -zxvf apr-1.4.6.tar.gz
$tar -zxvf apr-util-1.4.1.tar.gz
$tar -zxvf apache-log4cxx-0.10.0.tar.gz
- 编译前准备
注意配置前需进行以下操作:
1.vim src/main/cpp/inputstreamreader.cpp
增加#include <string.h>;
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/inputstreamreader.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/bytebuffer.h>
+
#include <string.h>
+
否则会出现inputstreamreader.cpp:66: error: 'memmove' was not declared in this scope
make[3]: *** [inputstreamreader.lo] 错误 1
2.vim src/main/cpp/socketoutputstream.cpp
增加#include <string.h>;
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/socketoutputstream.h>
#include <log4cxx/helpers/socket.h>
#include <log4cxx/helpers/bytebuffer.h>
+
#include <string.h>
+
否则会出现socketoutputstream.cpp:52: error: 'memcpy' was not declared in this scope
3.vim src/examples/cpp/console.cpp
增加#include <string.h>,#include <stdio.h>;
+
#include <stdio.h>
+
#include <stdlib.h>
+
#include <string.h>
+
#include <log4cxx/logger.h>
#include <log4cxx/consoleappender.h>
#include <log4cxx/simplelayout.h>
#include <log4cxx/logmanager.h>
#include <iostream>
#include <locale.h>
否则会出现
console.cpp: In function ‘int main(int, char**)’:
console.cpp:58: 错误:‘puts’在此作用域中尚未声明
- 编译安装
首先安装apr-1.4.6,切换cd apr-1.4.6,配置./configure --prefix=/usr/local/apr,接着make, make install
接着安装apr-util-1.4.1,切换至cd ../apr-util-1.4.1, ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr,接着make,make install;
最后安装apache-log4cxx-0.10.0,切换cd ../apache-log4cxx-0.10.0,配置./configure --prefix=/usr/local/log4cxx --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-charset=utf-8 --with-logchar=utf-8
./configure --prefix=build_path --with-apr=apr_path --with-apr-util=apr-util_path --with-charset=utf-8 --with-logchar=utf-