Solved

Ask a New Question

Posted on 2009-05-03
1
802 Views
Last Modified: 2012-05-06
I am supposed to use log4cxx in my application. But this is the first time I am working on logging. So I am trying a win32 console application with the use of log4cxx. (I am using visual studio 2008). I've build log4cxx to get the library files apr.lib, aprutil.lib, log4cxx.lib, xml.lib. Linked these files using 'Additional library directories' option of VS2008. The program compiles fine but when I try to build the code, I am getting

1>LINK : warning LNK4076: invalid incremental status file 'C:\Users\QSS4\Documents\Visual Studio 2008\Projects\ILogEx\Debug\ILogEx.ilk'; linking nonincrementally
1>   Creating library C:\Users\QSS4\Documents\Visual Studio 2008\Projects\ILogEx\Debug\ILogEx.lib and object C:\Users\QSS4\Documents\Visual Studio 2008\Projects\ILogEx\Debug\ILogEx.exp
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl log4cxx::BasicConfigurator::configure(void)" (__imp_?configure@BasicConfigurator@log4cxx@@SAXXZ) referenced in function "void __cdecl foo(void)" (?foo@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class log4cxx::helpers::ObjectPtrT<class log4cxx::Logger> __cdecl log4cxx::Logger::getLogger(char const * const)" (__imp_?getLogger@Logger@log4cxx@@SA?AV?$ObjectPtrT@VLogger@log4cxx@@@helpers@2@QBD@Z) referenced in function "void __cdecl `dynamic initializer for 'logger''(void)" (??__Elogger@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall log4cxx::helpers::ObjectPtrT<class log4cxx::Logger>::~ObjectPtrT<class log4cxx::Logger>(void)" (__imp_??1?$ObjectPtrT@VLogger@log4cxx@@@helpers@log4cxx@@UAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'logger''(void)" (??__Flogger@@YAXXZ)
1>C:\Users\QSS4\Documents\Visual Studio 2008\Projects\ILogEx\Debug\ILogEx.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Users\QSS4\Documents\Visual Studio 2008\Projects\ILogEx\ILogEx\Debug\BuildLog.htm"


I've tried putting the log4cxx.dll in the project directory in project directory at level of .sln file, at level of the code files and in debug directory. But I get the same error in all cases. What may be the problem here?

Thanks.


#include "log4cxx/logger.h"

#include "log4cxx/basicconfigurator.h"

#include "log4cxx/helpers/exception.h"

using namespace log4cxx;
 

#include "iostream"

using namespace std;
 

LoggerPtr logger(Logger::getLogger("Foo"));

void foo()

{

	BasicConfigurator::configure();

	cout<<"FOO";

}

Open in new window

0
Comment
Question by:Suhashk
1 Comment
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 250 total points
Comment Utility
>>>> Linked these files using 'Additional library directories' option of VS2008.
You additionally need to add the .lib files to the Linker - Input - Additional Dependencies.

The ''Additional library directories' id only for omitting the folders of these libs.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now