[libxml2][patch] Makefile modifications for Visual Studio 2017 community and 32bit compilation

Boris shtrasman <[email protected]>
Newsgroups gmane.comp.gnome.lib.xml.general
Message-ID <CAPM6V6PmFASNddxTgTOH5D5Z8j1jKsQjmaD74j5LGpjMt4ZVsw@mail.gmail.com>
Hi,

Here are patches for Makefile.msvc to allow build with Visual Studio 2017
(community ) in 32 bit mode (win32).

I have choose to target 32 bit to be as close as possible to Igor Zlatkovic
work (he also provides 32 bit versions.

I choose sdk 8.1 because it's the same sdk Igor targeted.

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
https://mail.gnome.org/mailman/listinfo/xml
0001-Allow-build-on-Visual-Studio-2017-community-edition-.patch (text/x-patch, 4.9 KB)
From 90fac6a5302fbc19da7f39f4a5bc3390203956f0 Mon Sep 17 00:00:00 2001
From: Boris Shtrasman <[email protected]>
Date: Wed, 16 Aug 2017 12:22:44 +0300
Subject: [PATCH] Allow build on Visual Studio 2017 community edition for WIN32
 on a 64 bit machine.

This patch hold the necessary changes to build libxml2 with Visual
Studio 2017 for WIN32 on a 64 bit machine.

Today 64 bit windows installation are very common, and Visual Studio
2017 community is the most recent version i have access to.

I have chosen 32 bit and SDK 8.1 to be as close as possible to Igor Zlatkovic work.
---
 win32/Makefile.msvc | 20 ++++++++++++++++----
 win32/Readme.txt    | 14 ++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc
index d16c1a2d..2e4d6f83 100644
--- a/win32/Makefile.msvc
+++ b/win32/Makefile.msvc
@@ -26,6 +26,18 @@ XML_IMP = $(XML_BASENAME).lib
 XML_DEF = $(XML_BASENAME).def
 XML_A = $(XML_BASENAME)_a.lib
 XML_A_DLL = $(XML_BASENAME)_a_dll.lib
+VS14_INCLUDE = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include"
+VS14_INCLUDE_AUX = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\include"
+VS14_INCLUDE_UCRT = "C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt"
+VS14_INCLUDE_UM = "C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um"
+VS14_INCLUDE_SHARED = "C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared"
+VS14_INCLUDE_WINRT = "C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\winrt\Include\um"
+WindowsSDK_IncludePath = "C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um"
+
+VC14_LINK_LIBRARY_PATH_X86 = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\lib\x86"
+VC14_LINK_LIBRARY_PATH_X86_AUX = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS\lib\x86"
+VC14_LINK_LIBRARY_PATH_X86_UCRT = "C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x86"
+VC14_LINK_LIBRARY_PATH_X86_WINSDK = "C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86"
 
 # Place where we let the compiler put its output.
 BINDIR = bin.msvc
@@ -36,14 +48,14 @@ UTILS_INTDIR = int.utils.msvc
 
 # The preprocessor and its options.
 CPP = cl.exe /EP
-CPPFLAGS = /nologo /I$(XML_SRCDIR)\include /D "NOLIBTOOL" 
+CPPFLAGS = /nologo /I$(XML_SRCDIR)\include /D "NOLIBTOOL"
 !if "$(WITH_THREADS)" != "no"
 CPPFLAGS = $(CPPFLAGS) /D "_REENTRANT"
 !endif
 
 # The compiler and its options.
 CC = cl.exe
-CFLAGS = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NOLIBTOOL" /W1 $(CRUNTIME)
+CFLAGS = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "NOLIBTOOL" /W1 $(CRUNTIME) /I$(VS14_INCLUDE) /I$(VS14_INCLUDE) /I$(VS14_INCLUDE_AUX) /I$(VS14_INCLUDE_UCRT) /I$(VS14_INCLUDE_UM) /I$(VS14_INCLUDE_SHARED) /I$(VS14_INCLUDE_WINRT) /I$(WindowsSDK_IncludePath)
 CFLAGS = $(CFLAGS) /I$(XML_SRCDIR) /I$(XML_SRCDIR)\include /I$(INCPREFIX)
 !if "$(WITH_THREADS)" != "no"
 CFLAGS = $(CFLAGS) /D "_REENTRANT"
@@ -65,8 +77,8 @@ CFLAGS = $(CFLAGS) /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
 
 # The linker and its options.
 LD = link.exe
-LDFLAGS = /nologo /VERSION:$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION)
-LDFLAGS = $(LDFLAGS) /LIBPATH:$(BINDIR) /LIBPATH:$(LIBPREFIX)
+LDFLAGS = /VERSION:$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION) /MACHINE:X86
+LDFLAGS = $(LDFLAGS) /LIBPATH:$(BINDIR) /LIBPATH:$(LIBPREFIX) /LIBPATH:$(VC14_LINK_LIBRARY_PATH_X86) /LIBPATH:$(VC14_LINK_LIBRARY_PATH_X86_AUX) /LIBPATH:$(VC14_LINK_LIBRARY_PATH_X86_UCRT) /LIBPATH:$(VC14_LINK_LIBRARY_PATH_X86_WINSDK)
 LIBS =
 !if "$(WITH_FTP)" == "1" || "$(WITH_HTTP)" == "1"
 LIBS = $(LIBS) wsock32.lib ws2_32.lib
diff --git a/win32/Readme.txt b/win32/Readme.txt
index 6b3edddb..8f45238b 100644
--- a/win32/Readme.txt
+++ b/win32/Readme.txt
@@ -148,6 +148,20 @@ it will link to its own C-runtime named msvcr70.dll or msvcr71.dll. This
 file is not available on any machine which doesn't have Visual Studio 
 .NET installed.
 
+2.1.1 UCRT and 32bit
+--------------------
+
+If you use the compiler which comes with Visual Studio 2015 and above, note that
+it will link to its own C-runtime named msvcr140.dll or msvcr140.dll. That 
+files are redistributed via the ucrt packages (windows XP need the ucrt files manually copied).
+
+In order to build 32 bit on Visual Studio 2017 on a 64 bit machine,
+ you would need to call the 32 bit compiler:
+
+step1 update your path to call the 32bit versions (assuming Visual studio installed to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017):
+set PATH="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x86";%PATH%
+step 2 call name
+nmake /f Makefile.msvc
 
 2.2 GNU C/C++, Mingw edition
 ----------------------------
-- 
2.13.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.