Hi,

I built the log4cxx library on WXP SP2 with no problems. But when I
try to link a very simple dll to it I get an unresolved symbol
problem. My problem is very similar to Sorin Popa (Nov 28 email). I
have some ideas on what the problem might be but I am not a very
strong C++ programmer and I have little experience on Windows as well
so I haven't been able to solve this. Details are below. Any help, or
gentle nudge in the right direction, would be greatly appreciated.

1) log4cxx build
- I'm using the HEAD from Nov. 13m 2006
- I built according to the instructions in INSTALL except:
 - I  added unxutils to my path so I could access the 'patch' command
 - I ran setenv.cmd from Microsoft Platform SDK for Windows Server 2003 R2 dir
- my command line was 'ant build'
- I ended up with a debug lib

2) my library
- the source consists of two files: EngineAppender.h & EngineAppender.cpp
EngineAppender.h listing:
#include <log4cxx/appenderskeleton.h>
#include <log4cxx/spi/loggingevent.h>
#include <log4cxx/helpers/pool.h>

class EngineAppender : public log4cxx::AppenderSkeleton {
 protected :
    void append(const log4cxx::spi::LoggingEventPtr& event,
                       log4cxx::helpers::Pool& p);
 public :
    void close();
    bool requiresLayout() const;
};

EngineAppender.cpp listing:
#include "EngineAppender.h"
#include "log4cxx/spi/loggingevent.h"

void EngineAppender::append(const log4cxx::spi::LoggingEventPtr& event,
                                           log4cxx::helpers::Pool& p) {
        event->getLoggerName();
}
void EngineAppender::close() { }
bool EngineAppender::requiresLayout() const {return 0;}

- before building I ran setenv.cmd to set up my environment
- then I ran
#include "EngineAppender.h"
#include "log4cxx/spi/loggingevent.h"

void EngineAppender::append(const log4cxx::spi::LoggingEventPtr&
event, log4cxx::helpers::Pool& p) {
        event->getLoggerName();
}

void EngineAppender::close() { }

bool EngineAppender::requiresLayout() const {
        return 0;
}

- I create the library with these two commands:
cl -DWIN32 -D_WIN32 -EHsc -Ilog4cxx/include -c EngineAppender.cpp
link -DLL EngineAppender.obj -out:test.dll log4cxxd.lib

It fails with the error:
EngineAppender.obj : error LNK2019: unresolved external symbol "public: class st
d::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
const __thiscall log4cxx::spi::LoggingEvent::getLoggerName(void)const " (?getLog
[EMAIL PROTECTED]@[EMAIL PROTECTED]@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@V?
[EMAIL PROTECTED]@2@@std@@XZ) referenced in function "protected: virtual void 
__thisc
all EngineAppender::append(class log4cxx::helpers::ObjectPtrT<class log4cxx::spi
::LoggingEvent> const &,class log4cxx::helpers::Pool &)" ([EMAIL PROTECTED]
@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@@[EMAIL PROTECTED]@@[EMAIL PROTECTED]@@Z
)

3) My troubleshooting
- In the log4cxx library the mangled name for getLoggerName is:
[EMAIL PROTECTED]@[EMAIL PROTECTED]@@[EMAIL PROTECTED]@[EMAIL 
PROTECTED]@@[EMAIL PROTECTED]@2@@std@@XZ

This differs from the name the linker is looking for in the
parameterized type to basic_string. The log4cxx library has _W (wchar)
and my linker is looking for a char type (D). (Sorin's linker was
looking for an unsigned short, G).

Even though I thought it would have no effect since I am using VC 8 I
tried compiling with the -Zc:wchar_t option. No change.

So, I'm stumped. How do I make my object file compile using
basic_string<wchar>? I cannot find anything on goolge (that I can
understand) that would help me solve this.

Thanks for your help,
charlie

Reply via email to