win10的跨编译ARARCH64/Linux生锈
我正在尝试从Windows互相编译,以获取64位ARMV8 / RASPBIAN(Dietpi),但我与第三方板条箱一起遇到了一系列问题。
我安装了
- ARMV8 GCC工具链(
- ” Studio 2019 C ++构建工具(来自这里)
- (Intellij Idea UE和Intellij插件-FYI,但与问题无关)。
从那里可以添加所需的目标 - 请注意,它取决于ARM GCC工具链(例如,32-- BIT版本是ARMV7 INKNOWN-LINUX-GNUEABIHF):
rustup target add aarch64-unknown-linux-gnu
然后,我编辑了%userProfile%\。货物\ config \/code
并添加了这些行:
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc.exe"
最后,我将它们添加到path :
- %userProfile%\。货物\ bin
- c:\ program Files(x86)\ Microsoft Visual Studio \ 2019 \ buildTools \ common7 \ councom7 \ iDe \ commonextensions \ microsoft \ microsoft \ cmake \ cmake \ cmake \ cmake \ cmake \ bin )
- C:\ Program Files(x86)\ Microsoft Visual Studio \ 2019 \ buildTools \ MSBUILD \ MSBUILD \ Current \ bin(对于 MSBUILD )
- [ARMV8 GCC工具链] \ bin
我如何交叉编译<> /strong>
确保Windows的所有内容都正确地编译并运行正确,我试图交叉编译:
cargo build -r --target=aarch64-unknown-linux-gnu
我遇到的问题
在用于简单应用程序时,很快就会很清楚许多板条箱无法编译。例如,freetype-sys
,这是我正在使用的绘图器
的依赖性:
error: failed to run custom build command for `freetype-sys v0.13.1`
Caused by:
process didn't exit successfully: `D:\projects\rust\humidity\rh\target\release\build\freetype-sys-4feef64f7ae6c484\build-script-build` (exit code: 101)
--- stdout
[...]
running: "cmake" "[...]\\freetype-sys-0.13.1\\freetype2" "-DWITH_BZip2=OFF" "-DWITH_HarfBuzz=OFF" "-DWITH_PNG=OFF" "-DWITH_ZLIB=OFF" "-DCMAKE_INSTALL_PREFIX=D:\\projects\\rust\\hum
idity\\rh\\target\\aarch64-unknown-linux-gnu\\release\\build\\freetype-sys-3464f88f9fbe3bc0\\out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_ASM_FLAGS=
-ffunction-sections -fdata-sections -fPIC" "-DCMAKE_BUILD_TYPE=Release"
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19043.
-- Configuring incomplete, errors occurred!
See also "D:/projects/rust/humidity/rh/target/aarch64-unknown-linux-gnu/release/build/freetype-sys-3464f88f9fbe3bc0/out/build/CMakeFiles/CMakeOutput.log".
--- stderr
CMake Error at CMakeLists.txt:119 (project):
Failed to run MSBuild command:
MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R) Build Engine version 16.0.462+g62fb89029d for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 11/06/2022 11:53:19.
Project "D:\projects\rust\humidity\rh\target\aarch64-unknown-linux-gnu\release\build\freetype-sys-3464f88f9fbe3bc0\out\build\CMakeFiles\3.13.19031502-MSVC_2\VCTargetsPath.vcxproj" on node 1 (default targets).
c:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(378,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build usin
g the v141 build tools, please install Visual Studio 2017 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [D:\p
rojects\rust\humidity\rh\target\aarch64-unknown-linux-gnu\release\build\freetype-sys-3464f88f9fbe3bc0\out\build\CMakeFiles\3.13.19031502-MSVC_2\VCTargetsPath.vcxproj]
Done Building Project "D:\projects\rust\humidity\rh\target\aarch64-unknown-linux-gnu\release\build\freetype-sys-3464f88f9fbe3bc0\out\build\CMakeFiles\3.13.19031502-MSVC_2\VCTargetsPath.vcxproj" (default targets) -- FAILED.
先前的板条箱需要2019年msbuild.exe的路径,因此较早的额外路径解决了这个问题。
这似乎需要MS VS 2017构建工具。这越来越绝望,所以我认为问题来自其他事情。
我还尝试了什么
edit1:
我注意到Visual Studio 2017的构建工具(版本15.9)(在这里)包括一个跨跨跨跨副校友64。因此,
- 我安装了此版本
- 启动了(有些隐藏的)vcvarsamd64_arm64.bat脚本,以设置环境
- 替换
aarch64-linux-gnu-gcc.exe
在>%userProfile%\ .cargo \ .cargo \ config中可执行
带有cl.exe
是MS Compiler/Linker。 - 从项目目录中,
货物清洁
货物构建-r -target = aarch64-inknown-linux-gnu
它比GCC工具链编译要快得多,但未能编译该编译Freetype板条箱:
Compiling freetype v0.7.0
error: could not find native static library `freetype`, perhaps an -L flag is missing?
GCC工具链和MS VC 2017的结果相同。
问题:与该目标交叉编译到底需要什么?我是否缺少某些内容?
- 我需要安装多个版本的VS构建工具吗?我想,如果它们都在
路径
中, - 我会需要分别安装Cmake,而不是使用VS中的一个,它们会发生冲突吗? (请参阅CMAKE前面定义的路径)
- 从Windows中根本不可能?
EDIT2:我开始相信freetype
Create> Create>已有几年没有更新,并且仍在0.7.0版中,由于某种原因无法交叉编译。
更新:我通过用其他东西替换绘图器
来解决问题。它删除了freetype
依赖关系(此模块确实有问题),并允许交叉兼容成功完成。
我仍然对解决问题的解决方案感兴趣,但是它可能涉及生成或找到目标库,并找到一种将其馈送到流程中的编译器的方法,因此它可能会令人费解。
I'm trying to cross-compile for a 64-bit ARMv8 / Raspbian (DietPi actually), from Windows, but I'm getting a series of issues with 3rd-party crates.
What I installed
- rust toolchain 1.61.0
- ARMv8 gcc toolchain (from here)
- MS Visual Studio 2019 C++ build tools (from here)
- (IntelliJ IDEA UE and the IntelliJ plugin - FYI but not really relevant to the question)
From there it is possible to add the required target - note that it's dependent on the ARM gcc toolchain (for example the 32-bit version is armv7-unknown-linux-gnueabihf):
rustup target add aarch64-unknown-linux-gnu
Then I edited %USERPROFILE%\.cargo\config
and added those lines:
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc.exe"
And finally, I added those to the PATH
:
- %USERPROFILE%\.cargo\bin
- c:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin (for cmake)
- c:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin (for msbuild)
- [ARMv8 gcc toolchain]\bin
How I cross-compiled
After making sure everything was compiling and running correctly for Windows, I tried to cross-compile:
cargo build -r --target=aarch64-unknown-linux-gnu
The problem I have
While this worked for simple applications, it quickly becomes clear that many crates fail to compile. For example, freetype-sys
, which is a dependency of plotters
that I'm using:
error: failed to run custom build command for `freetype-sys v0.13.1`
Caused by:
process didn't exit successfully: `D:\projects\rust\humidity\rh\target\release\build\freetype-sys-4feef64f7ae6c484\build-script-build` (exit code: 101)
--- stdout
[...]
running: "cmake" "[...]\\freetype-sys-0.13.1\\freetype2" "-DWITH_BZip2=OFF" "-DWITH_HarfBuzz=OFF" "-DWITH_PNG=OFF" "-DWITH_ZLIB=OFF" "-DCMAKE_INSTALL_PREFIX=D:\\projects\\rust\\hum
idity\\rh\\target\\aarch64-unknown-linux-gnu\\release\\build\\freetype-sys-3464f88f9fbe3bc0\\out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_ASM_FLAGS=
-ffunction-sections -fdata-sections -fPIC" "-DCMAKE_BUILD_TYPE=Release"
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19043.
-- Configuring incomplete, errors occurred!
See also "D:/projects/rust/humidity/rh/target/aarch64-unknown-linux-gnu/release/build/freetype-sys-3464f88f9fbe3bc0/out/build/CMakeFiles/CMakeOutput.log".
--- stderr
CMake Error at CMakeLists.txt:119 (project):
Failed to run MSBuild command:
MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R) Build Engine version 16.0.462+g62fb89029d for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 11/06/2022 11:53:19.
Project "D:\projects\rust\humidity\rh\target\aarch64-unknown-linux-gnu\release\build\freetype-sys-3464f88f9fbe3bc0\out\build\CMakeFiles\3.13.19031502-MSVC_2\VCTargetsPath.vcxproj" on node 1 (default targets).
c:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(378,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build usin
g the v141 build tools, please install Visual Studio 2017 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [D:\p
rojects\rust\humidity\rh\target\aarch64-unknown-linux-gnu\release\build\freetype-sys-3464f88f9fbe3bc0\out\build\CMakeFiles\3.13.19031502-MSVC_2\VCTargetsPath.vcxproj]
Done Building Project "D:\projects\rust\humidity\rh\target\aarch64-unknown-linux-gnu\release\build\freetype-sys-3464f88f9fbe3bc0\out\build\CMakeFiles\3.13.19031502-MSVC_2\VCTargetsPath.vcxproj" (default targets) -- FAILED.
A previous crate required the path to 2019 MSBuild.exe, hence the extra PATH earlier which solved that problem.
This one seems to require MS VS 2017 build tools. This is getting desperate, so I think the problem is coming from something else.
What else I have tried
EDIT1:
I noticed that the Build Tools for Visual Studio 2017 (version 15.9) (here) include a cross-compiler to ARM64. So
- I installed this version
- launched the (somewhat hidden) vcvarsamd64_arm64.bat script to setup the environment
- replaced the
aarch64-linux-gnu-gcc.exe
executable in%USERPROFILE%\.cargo\config
withcl.exe
which is the MS compiler/linker. - from the project directory,
cargo clean
cargo build -r --target=aarch64-unknown-linux-gnu
It compiles much faster than the gcc toolchain, but it fails compiling the freetype crate:
Compiling freetype v0.7.0
error: could not find native static library `freetype`, perhaps an -L flag is missing?
Same result with the gcc toolchain and MS VC 2017.
Question: What exactly is required to cross-compile to this target? Am I missing something?
- do I need to install several versions of VS build tools? I imagine they'll conflict if they're all in the
PATH
- do I need to install cmake separately, instead of using the one available in VS? (see PATH defined earlier with CMake)
- is it simply not possible from Windows?
EDIT2: I'm starting to believe that the freetype
create, which hasn't been updated for a few years and is still in version 0.7.0, cannot be cross-compiled for some reason.
UPDATE: I worked around the problem by replacing plotters
with something else. It removed the freetype
dependency (this module really has an issue) and allowed the cross-compilation to complete successfully.
I'm still interested by a solution to the problem, but it probably involves generating or finding the library for the target and finding a way to feed it to the compiler in the flow, so it may be somewhat convoluted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论