I have been using log4cxx 0.10.0 on Windows for a while now, and although the
INSTALL file says to use Ant when compiling with MSVC, my build was done using
the “configure.bat” method documented in site/building/vstudio.html. My notes
show a few differences from the documentation so I’ll include them here:
The directory structure looks like
import
apr
apr-util
log4cxx
Each directory includes the download archive for the utility with the same name.
The notes assume starting in import/log4cxx.
1. install sed. My version is sed-4.2-1-setup.exe.
2. cd ../apr
3. decompress apr-1.3.2.tar.bz2
4. move apr-1.3.2 to ../log4cxx/apr
5. cd ../apr-util
6. decompress apr-util-1.3.2.tar.bz2
7. move apr-util-1.3.2 to ../log4cxx/apr-util
8. cd ../log4cxx
9. decompress log4cxx-0.10.0.tar.gz
10. cd apache-log4cxx-0.10.0
11. type configure.bat | find "" /V > configure_dos.bat
12. configure_dos.bat
13. type configure-aprutil.bat | find "" /V > configure-aprutil_dos.bat
14. configure-aprutil_dos.bat
15. open projects/log4cxx.sln solution. When asked to convert the solution to
VC++<version>, click Yes to All.
16. Right click on Solution log4cxx and select Build solution.
If I remember correctly, there are some compile-time errors that have to be
corrected due to recent versions of MSVC becoming more strict with includes.
My build was made with MSVC++2012.
Best regards,
Alex Huang
From: Robert Middleton [mailto:[email protected]]
Sent: Thursday, April 23, 2015 11:58 AM
To: Log4CXX User
Subject: Re: Compiling on Windows
Update on the crash: I don't know what is going on with it, but I have
narrowed down how to reproduce it. It turns out that the macros for logging(
for example LOG4CXX_ERROR) create a log4cxx::helpers::MessageBuffer oss_;
object. This object gets created and the message is logged using it. If the
logging level is not valid, the MessageBuffer object is not created, and so the
crash does not occur.
The strange thing is that the crash happens at the end of the method that the
logging statement is in, it does *not* happen when the destructor of the
MessageBuffer is called. Windows indicates that this is a BEX error(buffer
overflow).
One solution that I saw was to make sure the library is compiled with /MD, I
checked the output for log4cxx and it is compiled with that, and my program is
compiled with -MD. Any ideas on what could be causing it?
-Robert Middleton
On Wed, Apr 22, 2015 at 10:05 PM, Robert Middleton
<[email protected]<mailto:[email protected]>> wrote:
Thorsten,
Thanks for the information. For future reference, here is what I needed to get
it to build:
* Windows compiler(cl). I had the Windows 7 SDK installed, which gave me
the command prompt with cl on PATH and the proper environment
* ant from: http://ant.apache.org/bindownload.cgi
* ant-contrib-1.0b3.jar from:
http://sourceforge.net/projects/ant-contrib/files/ant-contrib/
* cpptasks-1.0b5.jar from ant-contrib
* xercesImpl.jar from http://xerces.apache.org/mirrors.cgi#binary
I set my %PATH% to have the ant bin/ directory on it, and put the 3 jar files
on %CLASSPATH%. I then ran ant -Dfind=false -Ddebug=no. This built the
library; I added it to the .pro file with the following, after copying over the
.dll and .lib file to the directory with the .pro:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/ -llog4cxx
I then copied over the log4cxx include directory and put in logging. Everything
builds cleanly with MSVC, the problem is that as soon as something gets logged
my program crashes - it appears to be happening within log4cxx, since I can
cause it to happen by changing the level of a log statement.
-Robert Middleton
On Wed, Apr 22, 2015 at 3:38 AM, Thorsten Schöning
<[email protected]<mailto:[email protected]>> wrote:
Guten Tag Robert Middleton,
am Mittwoch, 22. April 2015 um 04:31 schrieben Sie:
> I want to use log4cxx on a Windows-based project, and I'm wondering
> what the easiest way to compile it for Windows is?
I guess that heavily depends on your compiler and toolchain, not sure
if I read about QT on the list in the past, so you may be the first
one trying. I would try to start using ANT and see how it's going, my
experience using Cygwin is not the best if it comes to building
software, but I didn't ever try with log4cxx.
https://logging.apache.org/log4cxx/building/ant.html
Mit freundlichen Grüßen,
Thorsten Schöning
--
Thorsten Schöning E-Mail:
[email protected]<mailto:[email protected]>
AM-SoFT IT-Systeme http://www.AM-SoFT.de/
Telefon...........05151- 9468- 55
Fax...............05151- 9468- 88
Mobil..............0178-8 9468- 04
AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow