473,545 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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/basicconfigurat or.h>
#include <log4cxx/propertyconfigu rator.h>
#include <log4cxx/helpers/exception.h>

using namespace std;
using namespace ost;
using namespace log4cxx;
using namespace log4cxx::helper s;

int main()
{
int result = EXIT_SUCCESS;
try
{
BasicConfigurat or::configure() ;
LoggerPtr rootLogger = Logger::getRoot Logger();

NDC::push(_T("t rivial context"));

rootLogger->debug(_T("debu g message"));
rootLogger->info(_T("inf o message"));
rootLogger->warn(_T("war n message"));
rootLogger->error(_T("erro r message"));
rootLogger->fatal(_T("fata l message"));
}
catch(Exception &)
{
result = EXIT_FAILURE;
}

return result;

}
I receive these error messages:
In function `main':
: undefined reference to `log4cxx::Basic Configurator::c onfigure()'
/home/maksim/tmp/ccvVAxjg.o(.tex t+0x44): In function `main':
: undefined reference to `log4cxx::Logge r::getRootLogge r()'

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 8743
ms******@gmail. com wrote:
log4cxx is an excellent library for logging [..]

undefined reference to `log4cxx::Basic Configurator::c onfigure()'
/home/maksim/tmp/ccvVAxjg.o(.tex t+0x44): In function `main':
>undefined reference to `log4cxx::Logge r::getRootLogge r()'

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.goo glegroups.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/basicconfigurat or.h>
#include <log4cxx/propertyconfigu rator.h>
#include <log4cxx/helpers/exception.h>

using namespace std;
using namespace ost;
using namespace log4cxx;
using namespace log4cxx::helper s;

int main()
{
int result = EXIT_SUCCESS;
try
{
BasicConfigurat or::configure() ;
LoggerPtr rootLogger = Logger::getRoot Logger();

NDC::push(_T("t rivial context"));

rootLogger->debug(_T("debu g message"));
rootLogger->info(_T("inf o message"));
rootLogger->warn(_T("war n message"));
rootLogger->error(_T("erro r message"));
rootLogger->fatal(_T("fata l message"));
}
catch(Exception &)
{
result = EXIT_FAILURE;
}

return result;

}
I receive these error messages:
In function `main':
: undefined reference to `log4cxx::Basic Configurator::c onfigure()'
/home/maksim/tmp/ccvVAxjg.o(.tex t+0x44): In function `main':
: undefined reference to `log4cxx::Logge r::getRootLogge r()'

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::Basic Configurator::c onfigure()'
/home/maksim/tmp/ccvVAxjg.o(.tex t+0x44): In function `main':
: undefined reference to `log4cxx::Logge r::getRootLogge r()'
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::Basic Configurator::c onfigure()'
/home/maksim/tmp/ccvVAxjg.o(.tex t+0x44): In function `main':
: undefined reference to `log4cxx::Logge r::getRootLogge r()'

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
2366
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 through a hierarchy (loggers) - Filtering filters (filters) - Thread safe library - UTF-16 Unicode support * Appenders:
10
23388
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
6449
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 up to this point. Some of the applications are class libraries which need to be callable via the COM interface from some of the older applications....
1
2953
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 because the timezone being used it GMT. I have tried to manually set a TZ environment variable, but it has not solved the problem. Does anyone have a way...
10
2659
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 .NET2003. also, when I do not try to link the fortran library (just to see if that was the cause), it builds the exe without any problems. i don't...
2
5862
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 Visual Studio, there are printed a lot of Memory Leaks errors: Detected memory leaks! Dumping objects -> {1323} normal block at 0x00BB6F20, 4...
3
2585
by: Bruintje Beer | last post by:
Hello, I have a question about log4cxx. How do I make a new appender class John
0
4070
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 up and stores the text being fed to it. Finally the LibrayBuilder is able to produce a Library which is the topic of this part of the article. ...
4
12955
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 been able to find a good answer to this and hope someone here who has experience can help me. I have researched the web and sites like this, and have...
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6003
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.