473,382 Members | 1,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

log4cxx library

log4cxx is an excellent library for logging with a huge amount
features:
http://logging.apache.org/log4cxx/ma...roduction.html
My friend persuaded me to install it. However, I have a problem
compiling a simple program. This is the program:
#include <iostream>
#include "server.h"

#include <log4cxx/logger.h>
#include <log4cxx/ndc.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/helpers/exception.h>

using namespace std;
using namespace ost;
using namespace log4cxx;
using namespace log4cxx::helpers;

int main()
{
int result = EXIT_SUCCESS;
try
{
BasicConfigurator::configure();
LoggerPtr rootLogger = Logger::getRootLogger();

NDC::push(_T("trivial context"));

rootLogger->debug(_T("debug message"));
rootLogger->info(_T("info message"));
rootLogger->warn(_T("warn message"));
rootLogger->error(_T("error message"));
rootLogger->fatal(_T("fatal message"));
}
catch(Exception&)
{
result = EXIT_FAILURE;
}

return result;

}
I receive these error messages:
In function `main':
: undefined reference to `log4cxx::BasicConfigurator::configure()'
/home/maksim/tmp/ccvVAxjg.o(.text+0x44): In function `main':
: undefined reference to `log4cxx::Logger::getRootLogger()'

I included all the header files needed. I think the problem is in how I
compile the program. Most likely, I miss a flag:
g++ -D_REENTRANT -pipe -O3 -march=i586 -fomit-frame-pointer
-I/home/maksim/projects/log4cxx-0.9.7/include -D_GNU_SOURCE
-L/usr/local/lib -lccgnu2 -ldl -lrt -pthread *.cpp -o server

Any help is appreciated (my program also uses GNU common C++ library).

Jul 26 '06 #1
6 8718
ms******@gmail.com wrote:
log4cxx is an excellent library for logging [..]

undefined reference to `log4cxx::BasicConfigurator::configure()'
/home/maksim/tmp/ccvVAxjg.o(.text+0x44): In function `main':
>undefined reference to `log4cxx::Logger::getRootLogger()'

I included all the header files needed. I think the problem is in how
I compile the program. Most likely, I miss a flag:
g++ -D_REENTRANT -pipe -O3 -march=i586 -fomit-frame-pointer
-I/home/maksim/projects/log4cxx-0.9.7/include -D_GNU_SOURCE
-L/usr/local/lib -lccgnu2 -ldl -lrt -pthread *.cpp -o server
Sorry, compiler-specific command-line options are off-topic here.
Please post to the g++ newsgroup: gnu.g++.help.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 27 '06 #2

<ms******@gmail.comschreef in bericht
news:11**********************@p79g2000cwp.googlegr oups.com...
log4cxx is an excellent library for logging with a huge amount
features:
http://logging.apache.org/log4cxx/ma...roduction.html
My friend persuaded me to install it. However, I have a problem
compiling a simple program. This is the program:
#include <iostream>
#include "server.h"

#include <log4cxx/logger.h>
#include <log4cxx/ndc.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/helpers/exception.h>

using namespace std;
using namespace ost;
using namespace log4cxx;
using namespace log4cxx::helpers;

int main()
{
int result = EXIT_SUCCESS;
try
{
BasicConfigurator::configure();
LoggerPtr rootLogger = Logger::getRootLogger();

NDC::push(_T("trivial context"));

rootLogger->debug(_T("debug message"));
rootLogger->info(_T("info message"));
rootLogger->warn(_T("warn message"));
rootLogger->error(_T("error message"));
rootLogger->fatal(_T("fatal message"));
}
catch(Exception&)
{
result = EXIT_FAILURE;
}

return result;

}
I receive these error messages:
In function `main':
: undefined reference to `log4cxx::BasicConfigurator::configure()'
/home/maksim/tmp/ccvVAxjg.o(.text+0x44): In function `main':
: undefined reference to `log4cxx::Logger::getRootLogger()'

I included all the header files needed. I think the problem is in how I
compile the program. Most likely, I miss a flag:
g++ -D_REENTRANT -pipe -O3 -march=i586 -fomit-frame-pointer
-I/home/maksim/projects/log4cxx-0.9.7/include -D_GNU_SOURCE
-L/usr/local/lib -lccgnu2 -ldl -lrt -pthread *.cpp -o server

Any help is appreciated (my program also uses GNU common C++ library).
Hi,

I guess you forget a namespace

John
Jul 27 '06 #3
Can you add the include & library path of log4cxx to your project ?

It didn't find references, because you didn't specify the library path
Jul 27 '06 #4
I think that you are right. However, I did not find a library in
log4cxx folder.
By the way, they provided several examples and a Makefile. This is the
file:
http://naturefoto.org/MAX/Makefile
Stephane Wirtel wrote:
Can you add the include & library path of log4cxx to your project ?

It didn't find references, because you didn't specify the library path
Jul 27 '06 #5
On 26 Jul 2006 16:40:41 -0700, ms******@gmail.com wrote:
>I receive these error messages:
In function `main':
: undefined reference to `log4cxx::BasicConfigurator::configure()'
/home/maksim/tmp/ccvVAxjg.o(.text+0x44): In function `main':
: undefined reference to `log4cxx::Logger::getRootLogger()'
This is a linker error ...
>I included all the header files needed. I think the problem is in how I
compile the program. Most likely, I miss a flag:
.... not a compiler error. Most likely you need to compile the library
and link the result to your application (e.g. with -lmylibname)
>g++ -D_REENTRANT -pipe -O3 -march=i586 -fomit-frame-pointer
-I/home/maksim/projects/log4cxx-0.9.7/include -D_GNU_SOURCE
-L/usr/local/lib -lccgnu2 -ldl -lrt -pthread *.cpp -o server

Any help is appreciated (my program also uses GNU common C++ library).
Try to find out how linking (of shared libraries) works on your
platform, also how include and library paths should be set up.

Best wishes,
Roland Pibinger
Jul 27 '06 #6
I added the path to the library, but now I am getting a run-time error:
cannot open shared object file: No such file or directory

I think that I installed log4cxx correctly since I followed all the
steps. Does that error message mean that log4cxx is not installed
correctly?
Roland Pibinger wrote:
On 26 Jul 2006 16:40:41 -0700, ms******@gmail.com wrote:
I receive these error messages:
In function `main':
: undefined reference to `log4cxx::BasicConfigurator::configure()'
/home/maksim/tmp/ccvVAxjg.o(.text+0x44): In function `main':
: undefined reference to `log4cxx::Logger::getRootLogger()'

This is a linker error ...
I included all the header files needed. I think the problem is in how I
compile the program. Most likely, I miss a flag:

... not a compiler error. Most likely you need to compile the library
and link the result to your application (e.g. with -lmylibname)
g++ -D_REENTRANT -pipe -O3 -march=i586 -fomit-frame-pointer
-I/home/maksim/projects/log4cxx-0.9.7/include -D_GNU_SOURCE
-L/usr/local/lib -lccgnu2 -ldl -lrt -pthread *.cpp -o server

Any help is appreciated (my program also uses GNU common C++ library).

Try to find out how linking (of shared libraries) works on your
platform, also how include and library paths should be set up.

Best wishes,
Roland Pibinger
Jul 27 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Michael CATANZARITI | last post by:
It's a flexible and highly configurable logging framework Main features : - Configurable logging destinations (appenders) - Configurable logging format (layouts) - Categorized logging statements...
10
by: Matthieu Labour | last post by:
Hi, I want to use a c++ version of log4j. But there are 3 of them :log4cpp, log4cplus, log4cx. Whis one is the best ? Thank you
2
by: pieter.breed | last post by:
Hi All, The company I work for has traditionally used COM/ActiveX for the solutions that it provides. We are in the process of moving to .NET and a few applications have been written in VB.NET...
1
by: Dan | last post by:
Hi, I have recently started using log4cxx and have hit a small snag. I am using the DailyRollingFileAppender and noticed that the rollovers are occuring 5 hours before they are supposed to...
10
by: Julian | last post by:
I get the following error when i try to link a fortran library to a c++ code in .NET 2005. LINK : fatal error LNK1104: cannot open file 'libc.lib' the code was working fine when built using...
2
by: asterixgallier | last post by:
Hello i'm having problems with log4cxx when using inside an MFC application build with visual studio 2005. The Application starts and works normaly, but while exiting, inside the DEBUG window of...
3
by: Bruintje Beer | last post by:
Hello, I have a question about log4cxx. How do I make a new appender class John
0
by: JosAH | last post by:
Greetings, the last two article parts described the design and implementation of the text Processor which spoonfeeds paragraphs of text to the LibraryBuilder. The latter object organizes, cleans...
4
by: Quidny | last post by:
Hi, This is a question pertaining to C++, so it seems to me to be on-topic here. If not, I apologize, and would ask which of these forums would be the correct one to used instead. I haven’t...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.