Solved

Ask a New Question

Posted on 2009-05-03
1
822 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
ID: 24293218
>>>> 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

756 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