Boost logo

Boost-Build :

Subject: Re: [Boost-build] [CMake] FindBoost: find both win32 and x64 static libs
From: Michael Jackson (mike.jackson_at_[hidden])
Date: 2010-12-07 21:35:47

On Dec 7, 2010, at 4:27 PM, Hicham Mouline wrote:

> From: philiplowman_at_[hidden] [mailto:philiplowman_at_[hidden]] On Behalf Of
> Philip Lowman
> Sent: 07 December 2010 13:17
> To: Hicham Mouline
> Cc: Philip Lowman; Dmytro Ovdiienko; CMake mailing list;
> boost-build_at_[hidden]
> Subject: Re: [CMake] FindBoost: find both win32 and x64 static libs
> On Sunday, December 5, 2010, Hicham Mouline <hicham_at_[hidden]> wrote:
> > I've built both win32 and x64 versions of boost thread library with the
>> following 2 lines:
>> 1. 32bit cl.exe from msvc9 directory in the %PATH%
>> bjam --with-thread --layout=versioned toolset=msvc address-model=64
>> variant=release link=static threading=multi runtime-link=shared
>> 2. 64bit cl.exe from msvc9 directory in the %PATH%
>> bjam --with-thread --layout=versioned toolset=msvc address-model=64
>> variant=release link=static threading=multi runtime-link=shared
>> however, the resulting .lib files have identical names however:
>> libboost_thread-vc90-mt-1_44.lib
>> libboost_thread-vc90-mt.lib
>> Dmytro, there is no distinction between 32bit and 64bit. The 64bit lib
> size
>> is approximately double the 32bit lib.
>> boost-build, how to change this to include the bitness in the boost lib
>> name?
>> If it's impossible, Philip, perhaps FindBoost could be changed to allow
> for
>> different directories under BOOST_ROOT for the lib directories, something
>> like lib\win32 and lib\x64 or whatever names can be agreed on.
> If the user is compiling 32-bit code I could make FindBoost search "lib32"
> before "lib" and for 64-bit code I can make it search "lib64" before "lib".
> If the user had an empty lib64 directory for some reason, it would still
> find the boost libraries in "lib".
> Would this work for you?
> The BOOST_LIBRARYDIR variable is the only other workaround I can think to
> this issue.
> ----------------------------------------
> Well I'd like to have other FindBoost users opinions.
> In terms of niceness (I believe there is no equivalent to Linux Standard
> Base which says where files should be on windows), I am flipping between:
> 1. c:\Program Files\boost\lib for 64bit libs and c:\Program Files
> (x86)\boost\lib for 32bit libs. I don't know where to put the headers then,
> maybe duplicate them in both directories. Then BOOST_ROOT is kind of
> irrelevant here.
> 2. C:\boost and then have lib32 lib64 under those, then BOOST_ROOT is
> c:\boost and your proposed change would be nice, though this somehow seems a
> little less "standard" to me.
> Shall we hear what other boosters say?
> Thanks,

I would see what the actual boost project has to say about this. BoostPro used to have precompiled binaries that got installed on windows. Where were those installed in the filesystem?

 Basically Windows is a crap-shoot. Nobody installs boost in the same location on windows and like Phillip said, Windows does not have anything like Linux Standard so your guess is as good as anyone else's. The best you can do is look for "BOOST_ROOT" and go from there. This is what the Boost project seems to advocate and it would be best if CMake could honor that as much as possible.

Just to add to the "Here is my setup" bandwagon this is how I set things up on my windows X64 system:

I have the following directories: C:\Developer\i386\Boost and C:\Developer\x64\Boost. I then have a pair of .bat files that get called each from a matching Command Prompt Shortcut. Each .bat file sets up the visual studio environment for either i386 or x64 and also sets the proper environment variables such as BOOST_ROOT. So when I configure a CMake project for use with Visual Studio for the first time I simply launch the proper Command Prompt (either i386 or x64) and run CMake from there. That way the proper environment is picked up. For completeness here is one of the .bat files:

@rem This is the vcvarsamd64.bat file. It is invoked using the argument
@rem "x64"
@SET VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 9.0
@SET VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
@SET FrameworkDir=C:\Windows\Microsoft.NET\Framework64
@SET FrameworkVersion=v2.0.50727
@SET Framework35Version=v3.5
@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR
@if "%VCINSTALLDIR%"=="" goto error_no_VCINSTALLDIR

@echo Setting environment for using Microsoft Visual Studio 2008 Beta2 x64 tools.

@call :GetWindowsSdkDir

@if not "%WindowsSdkDir%" == "" (
        set "PATH=%WindowsSdkDir%bin\x64;%WindowsSdkDir%bin\win64\x64;%WindowsSdkDir%bin;%PATH%"
        set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%"
        set "LIB=%WindowsSdkDir%lib\x64;%LIB%"

@set PATH=%VCINSTALLDIR%\BIN\amd64;%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%Framework35Version%\Microsoft .NET Framework 3.5 (Pre-Release Version);%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\VCPackages;%VSINSTALLDIR%\Common7\IDE;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%PATH%

@set LIBPATH=%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%FrameworkVersion%;%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\ATLMFC\LIB\amd64;%VCINSTALLDIR%\LIB\amd64;%LIBPATH%

@set ARCH_TYPE=x64
@set BOOST_ROOT=C:\Developer\%ARCH_TYPE%\MXABoost-1.44
@set EXPAT_INSTALL=C:\Developer\%ARCH_TYPE%\expat
@set HDF5_INSTALL=C:\Developer\%ARCH_TYPE%\hdf5-169
@set ITK_DIR=C:\Users\mjackson\Workspace\InsightToolkit-3.14.0\%ARCH_TYPE%
@set QTDIR=C:\Developer\%ARCH_TYPE%\Qt-4.6.2
@set BJAM_INSTALL=C:\Applications\bjam
@set SVN_INSTALL=C:\Applications\svn-1.5.6
@set CMAKE_INSTALL=C:\Applications\CMake-2.8.2
@set SEVENZIP_INSTALL=C:\Applications\7-Zip
@set JOM_INSTALL=C:\Applications\jom
@set QWT_INSTALL=C:\Developer\%ARCH_TYPE%\qwt-5.2.2



@goto end

@call :GetWindowsSdkDirHelper HKLM > nul 2>&1
@if errorlevel 1 call :GetWindowsSdkDirHelper HKCU > nul 2>&1
@if errorlevel 1 echo WindowsSdkDir not found
@exit /B 0

@SET WindowsSdkDir=
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows" /v "CurrentInstallFolder"') DO (
        if "%%i"=="CurrentInstallFolder" (
                SET "WindowsSdkDir=%%k"
@if "%WindowsSdkDir%"=="" exit /B 1
@exit /B 0

@echo ERROR: VSINSTALLDIR variable is not set.
@goto end

@echo ERROR: VCINSTALLDIR variable is not set.
@goto end


Mike Jackson
Principal Software Engineer mike.jackson_at_[hidden]
BlueQuartz Software Dayton, Ohio

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at