当前位置: 技术问答>linux和unix
ubuntu10.10下log4cplus使用报错
来源: 互联网 发布时间:2016-12-10
本文导语: 用g++ log_helloworld.cpp 报错如下: 源码来自官方: #include #include #include using namespace log4cplus; int main() { BasicConfigurator config; config.configure(); Logger logger = Logger::getInstance("main"); LOG4CPLUS_...
用g++ log_helloworld.cpp
报错如下:
源码来自官方:
/tmp/ccw0J73K.o: In function `main':
log_helloworld.cpp:(.text+0x17): undefined reference to `log4cplus::Logger::getDefaultHierarchy()'
log_helloworld.cpp:(.text+0x26): undefined reference to `log4cplus::BasicConfigurator::BasicConfigurator(log4cplus::Hierarchy&)'
log_helloworld.cpp:(.text+0x31): undefined reference to `log4cplus::PropertyConfigurator::configure()'
log_helloworld.cpp:(.text+0x68): undefined reference to `log4cplus::Logger::getInstance(std::basic_string const&)'
log_helloworld.cpp:(.text+0x9c): undefined reference to `log4cplus::Logger::~Logger()'
log_helloworld.cpp:(.text+0xd8): undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
log_helloworld.cpp:(.text+0x14e): undefined reference to `log4cplus::Logger::forcedLog(int, std::basic_string const&, char const*, int)'
log_helloworld.cpp:(.text+0x1a8): undefined reference to `log4cplus::Logger::~Logger()'
log_helloworld.cpp:(.text+0x1b9): undefined reference to `log4cplus::Logger::~Logger()'
log_helloworld.cpp:(.text+0x1ce): undefined reference to `log4cplus::BasicConfigurator::~BasicConfigurator()'
log_helloworld.cpp:(.text+0x1e5): undefined reference to `log4cplus::BasicConfigurator::~BasicConfigurator()'
collect2: ld returned 1 exit status
这是为什么,log4cplus版本1.0.3和1.0.4都试过,一样的错误,源码包里自带的例子是很正常的运行。
编译安装采用的命令为:
./configure
make
sudo make install
大家帮帮忙呀~
报错如下:
源码来自官方:
#include
#include
#include
using namespace log4cplus;
int
main()
{
BasicConfigurator config;
config.configure();
Logger logger = Logger::getInstance("main");
LOG4CPLUS_WARN(logger, "Hello, World!");
return 0;
}
/tmp/ccw0J73K.o: In function `main':
log_helloworld.cpp:(.text+0x17): undefined reference to `log4cplus::Logger::getDefaultHierarchy()'
log_helloworld.cpp:(.text+0x26): undefined reference to `log4cplus::BasicConfigurator::BasicConfigurator(log4cplus::Hierarchy&)'
log_helloworld.cpp:(.text+0x31): undefined reference to `log4cplus::PropertyConfigurator::configure()'
log_helloworld.cpp:(.text+0x68): undefined reference to `log4cplus::Logger::getInstance(std::basic_string const&)'
log_helloworld.cpp:(.text+0x9c): undefined reference to `log4cplus::Logger::~Logger()'
log_helloworld.cpp:(.text+0xd8): undefined reference to `log4cplus::Logger::isEnabledFor(int) const'
log_helloworld.cpp:(.text+0x14e): undefined reference to `log4cplus::Logger::forcedLog(int, std::basic_string const&, char const*, int)'
log_helloworld.cpp:(.text+0x1a8): undefined reference to `log4cplus::Logger::~Logger()'
log_helloworld.cpp:(.text+0x1b9): undefined reference to `log4cplus::Logger::~Logger()'
log_helloworld.cpp:(.text+0x1ce): undefined reference to `log4cplus::BasicConfigurator::~BasicConfigurator()'
log_helloworld.cpp:(.text+0x1e5): undefined reference to `log4cplus::BasicConfigurator::~BasicConfigurator()'
collect2: ld returned 1 exit status
这是为什么,log4cplus版本1.0.3和1.0.4都试过,一样的错误,源码包里自带的例子是很正常的运行。
编译安装采用的命令为:
./configure
make
sudo make install
大家帮帮忙呀~
|
编译文件的时候加上log4cplus的库