Building Log4cpp with VS2017

First, download log4cpp on sourceforge at http://log4cpp.sourceforge.net/ .Latest version is 1.1.3. Let’s decompress the archive.
Go to logcpp/msvc10 folder. Open the mvc10.sln and upgrade the project to latest SDK and Visual Studio 2017 (v141). Done.
Build the log4cpp project… There is an error about a custom build step on file NTEventLogCategories.mc.

We need to go into the folder msvc10 of the src and compile the event viewer definition file (.mc). You need to open Developer Command VS2017:

cd D:\Dev\log4cpp-1.1.3\log4cpp\msvc10>
D:\Dev\log4cpp-1.1.3\log4cpp\msvc10>mc NTEventLogCategories.mc

MC: Compiling NTEventLogCategories.mc

D:\Dev\log4cpp-1.1.3\log4cpp\msvc10>rc -r -fo NTEventLogCategories.res NTEventLogCategories.rc Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384 Copyright (C) Microsoft Corporation. All rights reserved.

D:\Dev\log4cpp-1.1.3\log4cpp\msvc10>link /MACHINE:IX86 -dll -noentry -out:NTEventLogAppender.dll NTEventLogCategories.res Microsoft (R) Incremental Linker Version 14.12.25830.2
Copyright (C) Microsoft Corporation. All rights reserved.

Then in Visual Studio, remove the NTEventLogCategories.mc file from the project and let’s BUILD !
There is a compiler error. To solve it: add HAVE_SNPRINTF to the Preprocessor definitions… and REBUILD ! Now it is successful:

1> Creating library Debug\log4cpp.lib and object Debug\log4cpp.exp
1>log4cpp.vcxproj -> D:\Dev\log4cpp-1.1.3\log4cpp\msvc10\log4cpp\Debug\log4cpp.dll 1>Done building project “log4cpp.vcxproj”.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Advertisements

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 )

Google+ photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this: