I am new to c++. I want to develop a transaction management system. in that case i have to maintain log files. I got the an API for log file creating. It is log4cpp. I installed it. I am using eclipse indigo for c++. I try with fallowing example code.
But in eclipse it's not work. And "log4cpp::Appender *appender = new log4cpp::FileAppender("FileAppender",LOGFILE);" line and other lines are indicate red colour. the compiler message is "undefined reference to `log4cpp::FileAppender::FileAppender(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool,
unsigned int)'". Please help me. I don't know how to config this. the preprocessor including not indicate red colour.
The two word phrase "undefined reference" in your error message suggests that it is not the compiler but the linker that is reporting the stated error.
You have to setup your project within Eclipse or configure Eclipse itself so that it not only knows where the header files are (from what you are saying, Eclipse has that figured already), but also know where the LIB or SO files are, for it to link your executable to the needed binary libraries.
Hopefully someone who is knowledgeable in configuring Eclipse can show you how to do that.
Also, if I may point out, the code you have reproduced is considered poor C++ style. Java and C++ are different languages, and writing C++ in a style that is almost Java-like, is considered poor form. There is seldom a need to "new" any object in C++.
hope this helps,
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery