aspose file tools*
The moose likes C / C++ and the fly likes log4cpp with eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » C / C++
Bookmark "log4cpp with eclipse" Watch "log4cpp with eclipse" New topic
Author

log4cpp with eclipse

dushantha Rathnayake
Ranch Hand

Joined: Feb 27, 2010
Posts: 103
Hi

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.



I got this code from http://joysofprogramming.com/simple-log4cpp-example/

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.

Thank you.
Anand Hariharan
Rancher

Joined: Aug 22, 2006
Posts: 257

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,
- Anand

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4cpp with eclipse