Monday 18 March 2013

Compiling XALAN for win64

Compiling XALAN 1.10

Here i have assumed that you already have a xerces compiled with you in a 64bit version, if not please refer to my previous blog post.

I have divided the compilation process into 3 parts, for easy understanding,

Part I : This will help you to create the intial environment to compile xalan library.
Part II : This will help you to compile Xalan messages library, which is needed by the xalan library.
Part III : Finally compiling the xalan library is described in this part.

----------------------------------------------------------------------------------------------------------------
PART I : Creating the environment.
----------------------------------------------------------------------------------------------------------------
Step 0 : In the root directory of xerces (not the xalan root) make sure you have the following folders,
lib -> Containing x64 compiled xerces .lib file in this directory.
bin -> Containing x64 compiled xerces .dll file in this directory.
include -> Containing the header files of xerces in this directory.

The easiest way to get the header files is, get a prepackaged binary distribution and copy the include directory out of that.

Step 0.5 : Create a environment variable XERCESCROOT , set this to the root directory of xerces.
To create a environment variable on windows 7,
Press start, right click on Computer and select properties.
Then in that windows, in the left panel, click Advanced system properties.
Then “System Properties” window opens, Clik the Environment Variables button and click new.

Then a dialog box appears saying “New User Variable”
Set Variable name as XERCESCROOT

Set Variable value as <path to xerces root folder>

----------------------------------------------------------------------------------------------------------------
PART II : Compiling for Xalan Messages
----------------------------------------------------------------------------------------------------------------
Step 1 : Go to <xalan_src_dir>\c\Projects\Win32\VC7.1\Utils
Step 2 : Create a file compile.bat and open it in a editor and add the following lines.
set XERCESCROOT=<path to your xerces install dir>
cd Localization
nmake /f BuildMessages.mak BITS=Win64 CFG=Release TYPE=inmem LOCALE=en_US
cd ..
Step 3 : Open <xalan_src_dir>\c\Projects\Win32\VC7.1\Utils\MsgCreator\MsgCreator.mak in a text editor. This file has several sections, one for each supported configuration.
Find the appropriate section, identified by the following line:
!ELSEIF "$(CFG)" == "MsgCreator - Win64 Release"
In that section, edit the CPP_PROJ variable, which contains the compiler command line to update obsolete, nonexistent, and missing parameters passed to the compiler.
/GX becomes /EHsc (this has to do with exception handling

Delete /YX and /Fp params (precompiled header junk)
/ML becomes /MD (has to do with which C runtime to link to. xerces used /MD)
Add /Zc:wchar_t- to disable wchar_t as a built-in type.

Step 4 : Edit the LINK32_FLAGS variable and replace /machine:IA64 at the end of that line with /machine:x64.
In the same line find /machine:IX86 and change it to /machine:x86 close the file.

Step 5 : Open <xalan_src_dir>\c\Projects\Win32\VC7.1\Utils\XalanMsgLib\XalanMsgLib.mak in a text editor.
Find the appropriate section, identified by a line like:
!ELSEIF "$(CFG)" == "XalanMsgLib - Win64 Release"

In that section, edit the CPP_PROJ variable, which contains the compiler command line to update obsolete, nonexistent, and missing parameters.

/GX becomes /EHsc (this has to do with exception handling
Delete /YX and /Fp params (precompiled header junk)
/ML becomes /MD (has to do with which C runtime to link to. xerces used /MD)

Add /Zc:wchar_t- to disable wchar_t as a built-in type.

Step 6 : Edit the LINK32_FLAGS variable and replace /machine:IA64 at the end of that line with /machine:x64.
In the same line find /machine:IX86 ans change it to /machine:x86
close the file.

Step 7 : Open a MSVC x64 command prompt, and from there, run the batch file you created previously. It should run successfully, but with many warnings, similar those we got when building xerces. Note that the output goes to:

<xalan_src_dir>\c\Build\Win64\VC7.1\Release

In this folder you will find the “XalanMessages_1_10” .dll and .lib files.

----------------------------------------------------------------------------------------------------------------
PART III : Compiling the Xalan library.
----------------------------------------------------------------------------------------------------------------
Step 8 : Start VC (Visual Studio) and load the Xalan VC project from <xalan_src_dir>\c\Projects\Win32\VC7.1\Xalan.sln.

Step 9 : Let the IDE convert the project to whatever version your IDE is.

Create x64 configurations for all the projects. ( I assume you know this..)
The AllInOne project is the one which creates the library. In the project properties for that project, for x64 configuration, make the following changes:
- C/C++->General: change "Win32" to "Win64" in the last path under Additional Include Directories.
- C/C++->Output Files: change "Win32" in all the output paths to "Win64".
- C/C++->Language: disable wchar_t as an built-in type.
- Linker->General: change "Win32" in the Output File path to "Win64", and again in the last path listed under Additional Library Directories.
- Linker->Advanced: change "Win32" to "Win64" in the path under Import Library.
Step 10 : Now close the visual studio window and open the file <xalan_src_dir>\c\Projects\Win32\VC7.1\AllInOne\AllInOne.vcproj in a text editor.
Step 11: Find "Release|x64" configuration in the file, then under the same tag scroll down to “VCLinkerTool” tag, there is an "AdditionalOptions" attribute that says /MACHINE:1386, delete that attribute. Close the editor and load up the solution again.
Step 12 : It is also advisable to add two more preprocessor symbols to the project, otherwise you will get a *lot* of warning spam (i got 5477 warnings) about use of insecure functions, and the build will take a lot longer: _SCL_SECURE_NO_WARNINGS, _CRT_SECURE_NO_WARNINGS
You can put the above macros in C/C++ -> Preprocessor -> Preprocessor Definitions

Step 13 : Build the AllInOne project, right click AllInOne in the Solution Explorer pane,
click Project Only->Build Only AllInOne.

The libraries are written to,
<xalan_src_dir>\c\Build\Win64\VC7.1\Release.
----------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment