Hello All,

 

I am trying to write a small VC++ application for Log C++.

But I am getting a linker error LNK2001 when I am trying to call a logger function.

I am linking the right Library file (log4cxx.lib) in the Projectà Settings à Link Tab. The link file is there in the same directory where my source CPP file is.

Could you please tell me why am I getting this and how do I resolve this problem.

 

Thanks,

Prabhakar

 

Here is the sample code

#include "stdlib.h"

#include "log4cxx/logger.h"

#include "log4cxx/basicconfigurator.h"

#include "log4cxx/helpers/exception.h"

#include "log4cxx/ndc.h"

 

using namespace log4cxx;

using namespace log4cxx::helpers;

 

int main()

{

    int result = EXIT_SUCCESS;

    try

    {

                        BasicConfigurator::configure();

                        LoggerPtr rootLogger = Logger::getRootLogger();

 

                        NDC::push(_T("Test 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;

}

 

 

The Error Message Is

TestLogCPP.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl log4cxx::NDC::push(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([EMAIL PROTECTED]@log4c

xx@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@[EMAIL PROTECTED]@2@@std@@@Z)

Release/TestLogCPP.exe : fatal error LNK1120: 1 unresolved externals

Error executing link.exe.

Reply via email to