You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Samuel Gundry <sa...@gmail.com> on 2009/10/30 07:14:29 UTC

ant build options not working on Windows? (unichar, wchar_t, etc)

Hi,

I'm tangling with log4cxx and going under...

I'm on Windows XP and using MSVC9 and used the following:
- apache-log4cxx-0.10.0.tar.gz
- apr-util-1.2.12.tar.gz                     (the latest didn't work,
can't remember the reason)
- apr-1.2.12.tar.gz                          (same again, latest
version didn't work)
- cpptasks-1.0b5                           (and built cpptasks.jar using ant)
- ant-contrib-1.0b5-bin                    (came with ant-contrib-1.0b3.jar)

(ant couldn't find tools.jar either. I 'solved' this by copying it
from the jdk/lib int jre/lib too, probably should've fixed paths or
something but ...)

Sorry for the long post. Please pick it apart and just answer what you
can or want. Thanks heaps for any help!


So to begin,  I have log4cxx building via ant:

$ant -Dfind=false

The library files are built and passes most but not all tests. I've
used it and it is logging. Fine. Great. Okay...

If I want to modify the build options, do I use the command line args
(-D...) or modify log4cxx.hw? The former doesn't seem to be working
for me.  That is, when I modify the build options, say
-Denable-wchar_t=yes, they don't seem to effect the generated
log4cxx.h.

So, if I run:
$ant -Dfind=false -Denable-wchar_t=yes -Denable-unichar=yes
-Dwith-logchar=wchar_t

generates the log4cxx.h as:
#define LOG4CXX_LOGCHAR_IS_UTF8 0
#if LOG4CXX_LOGCHAR_IS_UTF8
#define LOG4CXX_LOGCHAR_IS_WCHAR 0
#else
#define LOG4CXX_LOGCHAR_IS_WCHAR 1
#endif
#define LOG4CXX_LOGCHAR_IS_UNICHAR 0

#define LOG4CXX_CHAR_API 1
#define LOG4CXX_WCHAR_T_API 1
#define LOG4CXX_UNICHAR_API 0
#define LOG4CXX_CFSTRING_API 0


Why isn't LOG4CXX_UNICHAR_API  = 1?  What isn't
LOG4CXX_LOGCHAR_IS_UNICHAR = 1? Does it not make sense to have both
wchar_t and unichar enabled?

So, if I run:
$ant -Dfind=false -Denable-wchar_t=no -Denable-unichar=yes
-Dwith-logchar=unichar

#define LOG4CXX_LOGCHAR_IS_UTF8 0
#if LOG4CXX_LOGCHAR_IS_UTF8
#define LOG4CXX_LOGCHAR_IS_WCHAR 0
#else
#define LOG4CXX_LOGCHAR_IS_WCHAR 1
#endif
#define LOG4CXX_LOGCHAR_IS_UNICHAR 0

#define LOG4CXX_CHAR_API 1
#define LOG4CXX_WCHAR_T_API 1
#define LOG4CXX_UNICHAR_API 0
#define LOG4CXX_CFSTRING_API


No change.


So, now to try and use UTF8 and no wide characters:
$ant -Dfind=false -Denable-wchar_t=no -Denable -Dwith-logchar=utf-8

#define LOG4CXX_LOGCHAR_IS_UTF8 0
#if LOG4CXX_LOGCHAR_IS_UTF8
#define LOG4CXX_LOGCHAR_IS_WCHAR 0
#else
#define LOG4CXX_LOGCHAR_IS_WCHAR 1
#endif
#define LOG4CXX_LOGCHAR_IS_UNICHAR 0

#define LOG4CXX_CHAR_API 1
#define LOG4CXX_WCHAR_T_API 1
#define LOG4CXX_UNICHAR_API 0
#define LOG4CXX_CFSTRING_API


Again, no change.


So I've been modifying log4cxx.hw.  I seem to have wchar_t and utf-8
working independently. Can these be compiled into the same shared
library? Or do I need separate ones? And how should I handle the
modified header log4cxx.h when putting it into a dependency / 3rd
party folder? I.e., two includes folders?

However, back to the build. When I set the following, I get many
errors (can post if needed):
#define LOG4CXX_LOGCHAR_IS_UTF8 0
#if LOG4CXX_LOGCHAR_IS_UTF8
#define LOG4CXX_LOGCHAR_IS_WCHAR 0
#else
#define LOG4CXX_LOGCHAR_IS_WCHAR 0
#endif
#define LOG4CXX_LOGCHAR_IS_UNICHAR 1

#define LOG4CXX_CHAR_API 0
#define LOG4CXX_WCHAR_T_API 0
#define LOG4CXX_UNICHAR_API 1
#define LOG4CXX_CFSTRING_API


These are reduced when I include the char and wchar APIs...
#define LOG4CXX_LOGCHAR_IS_UTF8 0
#if LOG4CXX_LOGCHAR_IS_UTF8
#define LOG4CXX_LOGCHAR_IS_WCHAR 0
#else
#define LOG4CXX_LOGCHAR_IS_WCHAR 0
#endif
#define LOG4CXX_LOGCHAR_IS_UNICHAR 1

#define LOG4CXX_CHAR_API 1
#define LOG4CXX_WCHAR_T_API 1
#define LOG4CXX_UNICHAR_API 1
#define LOG4CXX_CFSTRING_API

...to:
- ndc.cpp(265) : error C2039: 'message' : is not a member of
'std::pair<_Ty1,_Ty2>'
- ndc.cpp(282) : error C2039: 'message' : is not a member of
'std::pair<_Ty1,_Ty2>'
- transcoder.cpp(35) : fatal error C1083: Cannot open include file:
'CoreFoundation/CFString.h': No such file or directory.

I looked at ndc.cpp and hacked / changed both lines 265 & 282 from:
Transcoder::encode(stack.top().message, dst);
to:
Transcoder::encode(getMessage(stack.top()), dst);

I had no idea and didn't look into it but it compiled; I was desperate.

But the second error is not hackable. Why is CoreFoundation required?

#if LOG4CXX_LOGCHAR_IS_UNICHAR || LOG4CXX_CFSTRING_API || LOG4CXX_UNICHAR_API
#include <CoreFoundation/CFString.h>
#endif


What I have I misunderstood?

The following doesn't complain (compile or run-time) but it the
characters appears as question marks in the output:
LOG4CXX_DEBUG(logger, LOG4CXX_STR("the message u30A8\u30FC\u30B8\u30A7"))

I guess it is something to do with the "with-charset" but I can't
modify the build options (-Dwith-charset) and I don't know where else
to modify this...

Again, sorry for the long post. Hopefully it makes sense - it is a
Friday night after all.

Cheers,
Sam