Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Ask a New Question

Posted on 2009-05-03
1
Medium Priority
?
846 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 1000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

876 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