log4cpp build/compile in mingw envrionment

Recently, we have one project which need porting linux program to windows.

Because this project used log4cpp to do logging operation, we log4cpp also need be ported.

Here I will record each issue during porting process.

1. Missing “config-MinGW32.h”, this is a common issue at the beginning. I think log4cpp developer forgot to packing this header file when release package.

This file can be found in CVS of log4cpp project.

2. ‘long long long’ is too long for GCC

$ g++ -I. -I../include -I../include -O2 -DNDEBUG -Wall -Wno-unused -pedantic –

MT Appender.lo -MD -MP -MF .deps/Appender.Tpo -c Appender.cpp -DDLL_EXPORT -DP

IC -o .libs/Appender.o

In file included from c:\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../include/wchar.h:405,

from c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:47,

from c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,

from c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/char_traits.h:42,

from c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/string:42,

from ../include/log4cpp/Appender.hh:14,

from Appender.cpp:11:

c:\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../include/stdint.h:33: error: ‘long long long’ is too long for GCC

a) Add –g3 and -save-temps to see preprocess source.

We see in temp reprocess file “Appender.ii” there are one line “typedef long long long long”, this is because:

in <stdint.h> “ typedef long long int64_t”,

but in config-MinGW32.h, int64_t was defined as “#define int64_t __int64”

and in <_mingw.h> __int64 was defined as “#define __int64 long long”

So error happened.

To fixing this issue, I comment one line in “config-MinGW32.h”, LINE 20: “#define int64_t __int64”

3. dd

C:/msys/1.0/bin/sh.exe ../libtool –tag=CXX –mode=compile g++ -DHAVE_CONFIG_H -I. -I../include -I../include -O2 -DNDEBUG -Wall -Wno-unused -pedantic -MT PatternLayout.lo -MD -MP -MF .deps/PatternLayout.Tpo -c -o PatternLayout.lo PatternLayout.cpp

g++ -DHAVE_CONFIG_H -I. -I../include -I../include -O2 -DNDEBUG -Wall -Wno-unused -pedantic -MT PatternLayout.lo -MD -MP -MF .deps/PatternLayout.Tpo -c PatternLayout.cpp -DDLL_EXPORT -DPIC -o .libs/PatternLayout.o

PatternLayout.cpp: In member function ‘virtual void log4cpp::PatternLayout::setConversionPattern(const std::string&)’:

PatternLayout.cpp:373: error: call of overloaded ‘abs(int&)’ is ambiguous

c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cmath:94: note: candidates are: double std::abs(double)

c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cmath:98: note: float std::abs(float)

c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cmath:102: note: long double std::abs(long double)

a) changed to “abs((double)xxx)” in PatternLayout.cpp

About Jack

Developer 雄关漫道真如铁,而今迈步从头越
This entry was posted in c++, mingw and tagged . Bookmark the permalink.

9 Responses to log4cpp build/compile in mingw envrionment

  1. sero says:


    i am trying to port a linux project into windows as well, did you build your project with log4cpp successfully? Is it any other problems that you haven’t mentioned here?

  2. Hah I am really the first comment to this awesome post?!?

  3. Kernald says:

    I’m also porting a project to Windows, using log4cpp, with MSYS and MinGW. At the end of the sh configure, I get :
    creating include/log4cpp/config.h – prefix LOG4CPP for include/config.h defines dirname: extra operand `/etc’
    Try `dirname –help’ for more information.
    /* automatically generated bcb5/ config/ doc/ include/ m4/ msvc6/ openvms/ src

    I don’t know if it is normal… So I ran make :
    makefile:722: *** target file `tags’ has both : and :: entries. Stop.

    An idea ?

  4. Kernald says:

    Ok, forget this. Removing one of the two “:” is ok. I got one more error : std::auto_ptr was not declared, missing an include of in BasicLayout.cpp.

    Now, it’s complaining about Doxygen… But make install runs pretty fine. So it’s ok.

  5. Viet says:

    Quite helpful your post.
    I got the same errors like yours and one extra.
    ./configure is ok
    make or make install give me this:

    BasicLayout.cpp:37 error: expected constructor, destructor, or type conversion before ‘<' token

    Do you have any idea ?
    ps: I compile the log4cpp-1.0 version

  6. Viet says:

    I don know where wordpress remove the word after #include my posts (security ???). Sorry for duplicated posts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s