简体   繁体   English

使用没有MASM的MinGW64构建Boost

[英]Building Boost with MinGW64 without MASM

I tried to build the Boost library for native 64bit using MinGW64 compiler, but got some failures. 我尝试使用MinGW64编译器为原生64位构建Boost库,但是遇到了一些失败。 Any pointers are appreciated. 任何指针都表示赞赏。 Thanks. 谢谢。

I got the bjam.exe (b2.exe) compiled in 64bit (with warning) and I used it the get the Boost built. 我得到了用64位编译的bjam.exe(b2.exe)(带警告),我用它来构建Boost。 I got the following error when building Boost.Context. 构建Boost.Context时出现以下错误。 (I wrote the command in batch for repeatable building). (我批量编写了可重复建筑的命令)。 Anything I missed? 我错过了什么?

  • Command: b2.exe install --prefix=%~dp0\\bld\\Boost.Build 命令:b2.exe install --prefix =%~dp0 \\ bld \\ Boost.Build
  • Error: 'ml64' is not recognized as an internal or external command, operable program or batch file. 错误:'ml64'未被识别为内部或外部命令,可运行程序或批处理文件。

I read the documentation and it said: 我阅读了文档并说:

Boost.Context must be built for the particular compiler(s) and CPU architecture(s)s being targeted. 必须为特定的编译器和目标CPU架构构建Boost.Context。 Boost.Context includes assembly code and, therefore, requires GNU AS for supported POSIX systems, and MASM for Windows systems. Boost.Context包含汇编代码,因此需要GNU AS用于支持的POSIX系统,MASM用于Windows系统。

So, is it possible to tell the bjam to use the as.exe included in my MinGW installation? 那么,是否可以告诉bjam使用我的MinGW安装中包含的as.exe? (As I have multiple MinGW, the location is not standard as C:\\MinGW\\bin) (因为我有多个MinGW,位置不标准为C:\\ MinGW \\ bin)

project-config.jam 项目config.jam中

import option ;
using gcc ; 
option.set keep-going : false ; 

Platform 平台

  • Windows 7 x64 Windows 7 x64
  • Boost 1.52.0 (source from sourceforge) 提升1.52.0(来自sourceforge)
  • MinGW 4.7.2 (rubenvb x64) MinGW 4.7.2(rubenvb x64)
  • No MSVC installation (no ml64.exe installed/found in my machine) 没有安装MSVC(我的机器上没有安装/找到ml64.exe)
  • Edit Problems occurred when installing WDK 编辑安装WDK时出现问题

Warning when building BJam , I think it can be ignored 在构建BJam时发出警告 ,我认为可以忽略它

function.c: In function 'check_alignment':
function.c:222:5: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

Full batch 全批量

SET OPATH=%PATH%
SET BOOST_VER=boost_1_52_0
SET "PATH_ZIP=C:\Program Files\7-zip"
SET "PATH_MINGW=C:\MinGW\rubenvb-4.7.2-64"
SET "PATH_SRC=%~dp0\%BOOST_VER%"
SET "PATH_BJAM=%PATH_SRC%\tools\build\v2\engine"

TITLE Extracting Packages ...
IF NOT EXIST "%PATH_SRC%.7z" GOTO :err_nozip
RD /S /Q "%PATH_SRC%"
"%PATH_ZIP%"\7z x "%PATH_SRC%.7z"

TITLE Building BJam ...
PUSHD "%PATH_BJAM%"
SET "PATH=%PATH_MINGW%\bin"
SET "BOOST_JAM_TOOLSET_ROOT=%PATH_MINGW%\"
CALL build.bat mingw --show-locate-target
SET PATH=%OPATH%
COPY "bin.ntx86_64\b2.exe" "%PATH_SRC%\" > nul
COPY "bin.ntx86_64\bjam.exe" "%PATH_SRC%\" > nul
POPD

TITLE Installing Boost Build...
PUSHD "%PATH_SRC%"
ECHO import option ; > project-config.jam
ECHO. >> project-config.jam
ECHO using gcc ; >> project-config.jam
ECHO. >> project-config.jam
ECHO option.set keep-going : false ; >> project-config.jam
ECHO. >> project-config.jam
b2.exe install --prefix=%~dp0\bld\Boost.Build
POPD

SET PATH=%OPATH%

This is a known issue for building Boost >~1.51 with MinGW. 这是使用MinGW构建Boost> ~1.51的已知问题。 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. 目前,使用MinGW构建Boost是因为Boost在为Windows构建Boost :: Context时依赖于MASM(在您的情况下为ml64),即使使用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 作为一个bodge你可以从微软网站获得MASM: http//www.microsoft.com/en-gb/download/details.aspx?id = 12654 32位版本,或者Windows驱动程序工具包64位版本: 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. 您可以在这里使用Boost bug跟踪器上提供的补丁: https//svn.boost.org/trac/boost/ticket/7262虽然只使用MinGW进行Boost :: Context编译,因此可以重新启用交叉编译促进。 You can also read the responses by Boost's Olli on the subject and his response to the subject. 您还可以阅读Boost的Olli关于该主题的回复以及他对该主题的回应。 Don't expect anything to be fixed in Boost for a while at least! 不要指望至少在Boost中修复一段时间!

Posting this answer here for the benefit of Google, because I've been struggling with this problem all day, and finally found a solution. 在这里发布这个答案是为了Google的利益,因为我整天都在努力解决这个问题,最后找到了解决方案。

Boost context will fail to link under MinGW if built with MASM 6, because it produces the EXPORT symbol. 如果使用MASM 6构建,则Boost上下文将无法在MinGW下链接,因为它会生成EXPORT符号。

This manifests as undefined reference to `make_fcontext' even though the library is linked correctly. 即使库正确链接,这也表现为undefined reference to `make_fcontext'

Objdump on the resulting library gives make_i386_ms_pe_masm.o: File format not recognized . 生成的库上的objdump给出了make_i386_ms_pe_masm.o: File format not recognized

The solution is to make sure you're using MASM 8. 解决方案是确保您使用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; 您可以从http://www.microsoft.com/en-us/download/confirmation.aspx?id=12654下载它 - 安装程序会对需要安装VC的问题感到厌烦,但您可以通过提取内容来绕过它安装程序使用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. 提取setup.exe并再次提取以获取.cab,并第三次提取并将生成的二进制文件重命名为ml.exe。

Then rebuild Boost with bjam --toolset=gcc --with-context -a stage . 然后用bjam --toolset=gcc --with-context -a stage重新bjam --toolset=gcc --with-context -a stage Boost bjam --toolset=gcc --with-context -a stage

Hopefully someone googling the same terms I've been googling all day will find this helpful. 希望有人在谷歌搜索我一直在谷歌搜索相同的条款将发现这有用。

According to Boost's requirements , you can find MASM64 in Microsoft's Windows Driver Kit (WDK). 根据Boost的要求 ,您可以在Microsoft的Windows驱动程序工具包(WDK)中找到MASM64。

I downloaded WDK 7 from Microsoft Download Center , and after installing it, I found ml64.exe in bin\\x86\\amd64 . 我从Microsoft下载中心下载了WDK 7,安装完成后,我在bin\\x86\\amd64找到了ml64.exe With that, I was able to successfully compile Boost 1.53.0. 有了这个,我能够成功编译Boost 1.53.0。

(If this is relevant still) This happens when your build folders have msvc artifacts left in there. (如果这仍然相关)当您的构建文件夹中还有msvc工件时,会发生这种情况。 I'm assuming your project-config.jam was initially 我假设你的project-config.jam最初是

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 并且您已为msvc构建,然后更改为“使用gcc”在这种情况下,您需要先发出以下内容

bjam --clean

which should clear the artifacts from msvc build and then you can issue and things should be fine 这应该清除msvc构建中的工件,然后你可以发布,事情应该没问题

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

by the way I saw you writing you had Windows 7 x64. 就像我看到你写的那样你有Windows 7 x64。 your bjam command needs to have adress-model=64 otherwise 32bit binaries will be produced... 你的bjam命令需要有adress-model = 64否则会生成32位二进制文​​件...

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. 有点晚了,但我设法在Windows 7上使用MinGW和WDK 7编译boost-modular(Git存储库,因此应该类似于2014年7月的1.55)。

The steps I used were 我使用的步骤是

  1. install MinGW and Msys (bash etc) using mingw-get-setup (the easy way), add bin/ to path 使用mingw-get-setup(简单方法)安装MinGW和Msys(bash等),添加bin /到路径
  2. install the Windows Driver Kit (for W7 I used WDK 7) -- GRMWDK_EN_7600_1.ISO 安装Windows驱动程序工具包(对于我使用WDK 7的W7) - GRMWDK_EN_7600_1.ISO
    downloading the ISO image and extracting the files with WinRAR worked for me 下载ISO映像并使用WinRAR解压缩文件对我有用
    the installer advises against installing the DSF, so skip that 安装程序建议不要安装DSF,所以跳过它
  3. add the directories of ML64.exe and ML.exe to the path (both required AFAIK) 将ML64.exe和ML.exe的目录添加到路径中(两者都需要AFAIK)
    C:\\Windows\\WinDDK\\7600.16385.1\\bin\\x86\\amd64;C:\\Windows\\WinDDK\\7600.16385.1\\bin\\x86 C:\\ WINDOWS \\ WINDDK \\ 7600.16385.1 \\ BIN \\ 86 \\ AMD64; C:\\ WINDOWS \\ WINDDK \\ 7600.16385.1 \\ BIN \\ X86
  4. open cmd.exe as administrator and start bash 以管理员身份打开cmd.exe并启动bash
  5. in the parent dir of boost, run 在boost的父目录中,运行
    git clone --recursive https://github.com/boostorg/boost.git boost > clone.log git clone --recursive https://github.com/boostorg/boost.git boost> clone.log
  6. exit bash, goto directory boost and run: bootstrap gcc 退出bash,goto目录提升并运行:bootstrap gcc
  7. if that finishes w/o problems (if ML64.exe is found), run 如果完成没有问题(如果找到ML64.exe),运行
    b2 -a -d+2 -q --build-type=complete --build-dir=build toolset=gcc link=shared runtime-link=shared threading=multi 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. 没有明确地将ML(64)目录添加到路径,我仍然得到关于ML的错误。

Installing MASM is not the same as installing MSVC. 安装MASM与安装MSVC不同。 I tried using different assemblers first but boost is not compatibe with their output. 我尝试先使用不同的汇编程序,但boost与它们的输出不兼容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM