Search code examples
c++boostbatch-filemingwbjam

Building Boost 1.52 with non-standard location of MinGW


I tried to build Boost from source for 64bit using MinGW (x64) but failed when creating the bjam.exe. Any pointer to help is appreciated. Thanks.

  • Package: Boost 1.52.0 (download from sourceforge, C:\BoostSrc)
  • Package: MinGW-w64 (4.7.2-x64 rubenvb, C:\MinGW\rubenvb-4.7.2-64)

I created the following batch file to ensure repeatable building, but things got wrong. I cannot build the bjam.exe with supplied batch file. I'm not using the supplied "bootstrap.bat" as the non-standard installation path of MinGW (I have multiple mingw sets), and I have no MSVC installed in my machine

SET BOOST_VER=boost_1_52_0
SET PATH_MINGW=C:\MinGW\rubenvb-4.7.2-64
SET PATH_BJAM=%~dp0\%BOOST_VER%\tools\build\v2\engine
SET PATH="%PATH_MINGW%\bin"
PUSHD "%PATH_BJAM%"

REM check path
mingw32-make -version

REM error below
build.bat mingw --toolset-root=%PATH_MINGW% --show-locate-target

SET PATH=%OPATH%
POPD
REM ... some more ...

Error message

gcc: error: CreateProcess: No such file or directory

When I type the command directly from command prompt (set the path, go to location and invoke build.bat), it goes smoothly (with warnings which i think can be ignored)


Solution

  • After digging into build.bat located at BOOST_ROOT\tools\build\v2\engine, when supplying "mingw" as the toolset, the script by-passed the "guessing toolset" step and failed to define the variable "BOOST_JAM_TOOLSET_ROOT", leaving calls to gcc-related executables failed.

    Now I changed the batch as follow

    PUSHD "%PATH_BJAM%"
    SET "PATH=%PATH_MINGW%\bin"
    
    REM add the line below
    SET "BOOST_JAM_TOOLSET_ROOT=%PATH_MINGW%\"
    
    build.bat mingw --show-locate-target
    SET PATH=%OPATH%
    

    I manually set the BOOST_JAM_TOOLSET_ROOT variable from external batch file and this worked fine. Beware of the ending "\" character, as the build.bat inside append the path variable as this:

    set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
    

    Thanks very much for any comments and suggestions.