Building Boost with MinGW64 without MASM

前端 未结 5 2131
孤街浪徒
孤街浪徒 2021-01-06 14:11

I tried to build the Boost library for native 64bit using MinGW64 compiler, but got some failures. Any pointers are appreciated. Thanks.

I got the bjam.exe (b2.exe)

相关标签:
5条回答
  • 2021-01-06 14:32

    According to Boost's requirements, you can find MASM64 in Microsoft's Windows Driver Kit (WDK).

    I downloaded WDK 7 from Microsoft Download Center, and after installing it, I found ml64.exe in bin\x86\amd64. With that, I was able to successfully compile Boost 1.53.0.

    0 讨论(0)
  • 2021-01-06 14:34

    Posting this answer here for the benefit of Google, because I've been struggling with this problem all day, and finally found a solution.

    Boost context will fail to link under MinGW if built with MASM 6, because it produces the EXPORT symbol.

    This manifests as undefined reference to `make_fcontext' even though the library is linked correctly.

    Objdump on the resulting library gives make_i386_ms_pe_masm.o: File format not recognized.

    The solution is to make sure you're using MASM 8.

    You can download it at http://www.microsoft.com/en-us/download/confirmation.aspx?id=12654 - the installer will bitch about needing to have VC installed, but you can just bypass this by extracting the contents of the installer using a tool such as WinRAR; extract setup.exe and extract again to get a .cab, and extract a third time and rename the resulting binary file to ml.exe.

    Then rebuild Boost with bjam --toolset=gcc --with-context -a stage.

    Hopefully someone googling the same terms I've been googling all day will find this helpful.

    0 讨论(0)
  • 2021-01-06 14:38

    A bit late maybe but I managed to compile boost-modular (the Git repository, so should be similar to 1.55 as of July 2014) on Windows 7, using MinGW and the WDK 7.

    The steps I used were

    1. install MinGW and Msys (bash etc) using mingw-get-setup (the easy way), add bin/ to path
    2. install the Windows Driver Kit (for W7 I used WDK 7) -- GRMWDK_EN_7600_1.ISO
      downloading the ISO image and extracting the files with WinRAR worked for me
      the installer advises against installing the DSF, so skip that
    3. add the directories of ML64.exe and ML.exe to the path (both required AFAIK)
      C:\Windows\WinDDK\7600.16385.1\bin\x86\amd64;C:\Windows\WinDDK\7600.16385.1\bin\x86
    4. open cmd.exe as administrator and start bash
    5. in the parent dir of boost, run
      git clone --recursive https://github.com/boostorg/boost.git boost > clone.log
    6. exit bash, goto directory boost and run: bootstrap gcc
    7. if that finishes w/o problems (if ML64.exe is found), run
      b2 -a -d+2 -q --build-type=complete --build-dir=build toolset=gcc link=shared runtime-link=shared threading=multi

    Without explicitly adding the ML(64) directories to the path, I still got the errors about ML.

    Installing MASM is not the same as installing MSVC. I tried using different assemblers first but boost is not compatibe with their output.

    0 讨论(0)
  • 2021-01-06 14:39

    (If this is relevant still) This happens when your build folders have msvc artifacts left in there. I'm assuming your project-config.jam was initially

    import option ;
    using msvc ; 
    

    and you had built for msvc then changed to "using gcc" In that case you need to issue the following first

    bjam --clean
    

    which should clear the artifacts from msvc build and then you can issue and things should be fine

    bjam toolset=gcc variant=..... and so on and on
    

    by the way I saw you writing you had Windows 7 x64. your bjam command needs to have adress-model=64 otherwise 32bit binaries will be produced...

    0 讨论(0)
  • 2021-01-06 14:40

    This is a known issue for building Boost >~1.51 with MinGW. At the moment, building Boost with MinGW is broken because Boost has a dependency on MASM (in your case ml64) when building Boost::Context for Windows, even with MinGW.

    As a bodge you can get MASM from the Microsoft Website: http://www.microsoft.com/en-gb/download/details.aspx?id=12654 for a 32-bit version, or else the Windows Driver Kit for the 64-bit version: http://msdn.microsoft.com/en-us/windows/hardware/hh852365.aspx

    You can use the patch provided on the Boost bug tracker here: https://svn.boost.org/trac/boost/ticket/7262 though to make Boost::Context compile with just MinGW, thus re-enabling cross-compilation of Boost. You can also read the responses by Boost's Olli on the subject and his response to the subject. Don't expect anything to be fixed in Boost for a while at least!

    0 讨论(0)
提交回复
热议问题