C++/Building boost libraries for 64-bit windows targets
You mentioned in your answer to another question that you have configured the boost libraries to build on Windows XP Professional x64 Edition for 32-bit and 64-bit targets.
Can you please share your build configuration?
In theory yes. However I remember the process was painful - especially as this was my first time installing and building Boost, and I did this some time ago now. So thank you for asking as I have been meaning to better track my changes for a while and this question has forced me to do so.
I had intended to submit my changes to Boost but was put off by the requested procedure to do so (specifically which patch utility do they use, as MS Windows systems do not have a native patch utility?). I kept intending to have another go but never got around to it. If you are familiar with this procedure then I would appreciate some help.
I only built the boost libraries using the MSVC++ 8 (2005) compiler for 32-bit x86 and 64-bit AMD x64 using the native AMD x64 VC++ compiler running under Windows XP Professional x64 Edition. Specifically I did not use the x86/x64 cross compiler. Note that there is no support in Boost for IA64 architecture builds as far as I could tell. I also only modified v1 jam build files.
I am using Boost version 1.33.1 (i.e. I have a boost_1_33_1 directory).
I assume you know how to set up a VC8 command line session for and x64 build (e.g. by running the vcvarsall.bat file found in the MS Visual Studio 2005 installation tree, with a parameter of amd64 or x64, or selecting the Start > Programs > Microsoft Visual Studio 2005 > Visual Studio Tools > Visual Studio 2005 x64 Win64 Command Prompt Start menu item).
I ended up having to do the following:
- Modifying some of the Boost build files.
- Modifying one of the Boost thread library source files to build for Win64.
The build files I modified were in the <boost-root>\tools\build\v1 directory.
In the file msvc-tools.jam I modified the linker command line around line 158, in the:
actions together vc-Link
section to reverse the order in which "$(LIBPATH)" and "$(STDLIBPATH)" are mentioned. In my version "$(STDLIBPATH)" is the argument to the first /LIBPATH option:
"$(VC_TOOL_PATH)$(VC_LINKER)" /nologo $(NOINCREMENTAL) $(LINKFLAGS) $(PDB_LINKFLAG)"$(VC_PDB_FILE)" /out:"$(<)" /IMPLIB:"$(<)" /LIBPATH:"$(STDLIBPATH)" /LIBPATH:"$(LIBPATH)" "$(FINDLIBS:S=.lib)" @"$(>)"
(the above is all _one_ line but may well have been split when posting through AllExperts). I do not remember if this was just the result of my playing around or if this is in fact necessary - sorry!
In the file vc-8_0-amd64-tools.jam I appended the following four lines:
STDLIBPATH = $(MSVCDir)$(SLASH)lib$(SLASH)amd64 ;
LIBPATH = $(MSVCDir)$(SLASH)PlatformSDK$(SLASH)lib$(SLASH)amd64 ;
FINDLIBS = Kernel32 ;
flags vc-8_0 C++FLAGS : /Wp64 ;
Modifying these two files should allow you to build a native AMD x64 build of the Boost libraries using MSVC++ 8 in amd64 configuration. As I mentioned above I did not attempt to build an x64 version of Boost using the VC8 x86/x64 cross compiler so did not use, look at or modify the vc-8_0-x86_amd64-tools.jam file.
The next problem you will encounter is that the Boost thread library does not build. This is due to changes to the platform SDK between Win32 and Win64, specifically that Win64 does _not_ support InterlockedCompareExchange as a function exported from kernel32, and used in the Boost thread library once.cpp source file. However, the MSVC++ 8 compiler does support this operation as an intrinsic function for both Win32 and Win64.
In the file once.cpp, in the directory <boost-root>\libs\thread\src, I made the following changes:
After the line:
# if BOOST_MSVC >= 1400
# include <intrin.h>
# pragma intrinsic(_InterlockedCompareExchange)
inline LONG compare_exchange(volatile LPLONG dest, LONG exch, LONG cmp)
return _InterlockedCompareExchange(dest, exch, cmp);
(note: for brevity I have removed an explanatory comment)
Then _before_ the line:
#endif // defined(BOOST_HAS_WINTHREADS)
# endif // BOOST_MSVC >= 1400
I do not know if any other compilers support Win64 on the x64 edition of Windows XP, and are supported by Boost, but my fix is very compiler specific.
As far as I can tell these are the only files I modified.
Hope these changes help you out.