本文主要是介绍conan入门(二十七):因profile [env]字段废弃导致的boost/1.81.0 在aarch64-linux-gnu下交叉编译失败,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
今天在尝试用conan 1.60.0使用aarch64-linux-gnu编译器交叉编译boost/1.81.0时报错了:
conan install boost/1.81.0@ -pr:h aarch64-linux-gnu.jinja -pr:b default --build boost
输出如下:
Configuration (profile_host):
[settings]
arch=armv8
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=7
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
AR=aarch64-linux-gnu-ar
AS=aarch64-linux-gnu-as
CC=aarch64-linux-gnu-gcc
CHOST=aarch64-linux-gnu
CONAN_CMAKE_GENERATOR=Unix Makefiles
CONAN_CMAKE_TOOLCHAIN_FILE=/home/gyd/.conan/profiles/../cmake/aarch64-linux-gnu.toolchain.cmake
CROSS_COMPILER_PREFIX=/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu
CXX=aarch64-linux-gnu-g++
LD=aarch64-linux-gnu-ld
RANLIB=aarch64-linux-gnu-ranlib
STRIP=aarch64-linux-gnu-strip
Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux
os_build=Linux
[options]
[build_requires]
[env]boost/1.81.0: Forced build from source
Installing package: boost/1.81.0
Requirementsboost/1.81.0 from 'pub' - Cachebzip2/1.0.8 from 'pub' - Cachelibbacktrace/cci.20210118 from 'pub' - Cachezlib/1.2.13 from 'pub' - Cache
Packagesboost/1.81.0:3aac81ffa04cca0028f0506d5a46ab398161b6d4 - Buildbzip2/1.0.8:75c0a8a066a2422a4e85cba63decf52760f1010c - Cachelibbacktrace/cci.20210118:8fd38d381db52e2495321ce060b9f457656f6c8f - Cachezlib/1.2.13:8fd38d381db52e2495321ce060b9f457656f6c8f - Cache
Build requirementsb2/4.9.6 from 'conancenter' - Cache
Build requirements packagesb2/4.9.6:4db1be536558d833e52e862fd84d64d75c2b3656 - CacheCross-build from 'Linux:x86_64' to 'Linux:armv8'
Installing (downloading, building) binaries...
b2/4.9.6: Already installed!
bzip2/1.0.8: Already installed!
libbacktrace/cci.20210118: Already installed!
zlib/1.2.13: Already installed!
boost/1.81.0: Applying build-requirement: b2/4.9.6
boost/1.81.0: WARN: Build folder is dirty, removing it: /home/gyd/.conan/data/boost/1.81.0/_/_/build/3aac81ffa04cca0028f0506d5a46ab398161b6d4
boost/1.81.0: Building your package in /home/gyd/.conan/data/boost/1.81.0/_/_/build/3aac81ffa04cca0028f0506d5a46ab398161b6d4
boost/1.81.0: Generator txt created conanbuildinfo.txt
boost/1.81.0: Calling generate()
boost/1.81.0: Aggregating env generators
boost/1.81.0: Calling build()
boost/1.81.0: WARN: replace_in_file didn't find pattern '$(>) > $(<)' in '/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/libs/stacktrace/build/Jamfile.v2' file.
boost/1.81.0: WARN: replace_in_file didn't find pattern '/* thread_local */' in '/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/boost/stacktrace/detail/libbacktrace_impls.hpp' file.
boost/1.81.0: WARN: replace_in_file didn't find pattern '/* static __thread */' in '/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/boost/stacktrace/detail/libbacktrace_impls.hpp' file.
boost/1.81.0: WARN: replace_in_file didn't find pattern 'local generic-os = [ set.difference $(all-os) : aix darwin vxworks solaris osf hpux ] ;' in '/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/tools/build/src/tools/gcc.jam' file.
boost/1.81.0: WARN: replace_in_file didn't find pattern 'local no-threading = android beos haiku sgi darwin vxworks ;' in '/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/tools/build/src/tools/gcc.jam' file.
boost/1.81.0: WARN: replace_in_file didn't find pattern ' <conditional>@numa' in '/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/libs/fiber/build/Jamfile.v2' file.
boost/1.81.0: WARN: Patching user-config.jam
boost/1.81.0: WARN:
using zlib : 1.2.13 : <include>"/home/gyd/.conan/data/zlib/1.2.13/_/_/package/8fd38d381db52e2495321ce060b9f457656f6c8f/include" <search>"/home/gyd/.conan/data/zlib/1.2.13/_/_/package/8fd38d381db52e2495321ce060b9f457656f6c8f/lib" <name>z ;
using bzip2 : 1.0.8 : <include>"/home/gyd/.conan/data/bzip2/1.0.8/_/_/package/75c0a8a066a2422a4e85cba63decf52760f1010c/include" <search>"/home/gyd/.conan/data/bzip2/1.0.8/_/_/package/75c0a8a066a2422a4e85cba63decf52760f1010c/lib" <name>bz2 ;
using "gcc" : : "/usr/bin/g++" :
<compileflags>"-I/home/gyd/.conan/data/libbacktrace/cci.20210118/_/_/package/8fd38d381db52e2495321ce060b9f457656f6c8f/include" <linkflags>"-L/home/gyd/.conan/data/libbacktrace/cci.20210118/_/_/package/8fd38d381db52e2495321ce060b9f457656f6c8f/lib" ;
boost/1.81.0: Cross building, detecting compiler...
boost/1.81.0: Cross building flags: []
boost/1.81.0: WARN: b2 -q numa=on target-os=linux architecture=arm address-model=64 binary-format=elf abi=aapcs --layout=system --user-config=/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/tools/build/user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=on boost.locale.iconv.lib=libc threading=multi visibility=hidden link=static variant=release --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-fiber --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-url --with-wave toolset=gcc define=_GLIBCXX_USE_CXX11_ABI=1 pch=on -sLIBBACKTRACE_PATH=/home/gyd/.conan/data/libbacktrace/cci.20210118/_/_/package/8fd38d381db52e2495321ce060b9f457656f6c8f linkflags="" cxxflags="-fPIC -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/home/gyd/.conan/data/boost/1.81.0/_/_/package/3aac81ffa04cca0028f0506d5a46ab398161b6d4 -j4 --abbreviate-paths -d0 --debug-configuration --build-dir="/home/gyd/.conan/data/boost/1.81.0/_/_/build/3aac81ffa04cca0028f0506d5a46ab398161b6d4/build-release"
notice: found boost-build.jam at /home/gyd/.conan/data/boost/1.81.0/_/_/source/src/boost-build.jam
notice: loading B2 from /home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/kernel/bootstrap.jam
notice: Searching '/etc' '/home/gyd' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/kernel' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/util' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/build' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/tools' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/contrib' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/.' for site-config configuration file 'site-config.jam'.
notice: Configuration file 'site-config.jam' not found in '/etc' '/home/gyd' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/kernel' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/util' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/build' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/tools' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/contrib' '/home/gyd/.conan/data/b2/4.9.6/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin/.b2/.'.
notice: Loading explicitly specified user configuration file:/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/tools/build/user-config.jam
notice: Searching '/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/tools/build' for user-config configuration file 'user-config.jam'.
notice: Loading user-config configuration file 'user-config.jam' from '/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/tools/build'.
notice: [zlib] Using pre-installed library
notice: [zlib] Condition
notice: [bzip2] Using pre-installed library
notice: [bzip2] Condition
notice: will use '/usr/bin/g++' for gcc, condition <toolset>gcc-11
notice: using gcc libraries :: <toolset>gcc-11 :: /usr/bin /usr/lib /usr/lib32 /usr/lib64
notice: using gcc archiver :: <toolset>gcc-11 :: /usr/bin/ar
warning: toolset gcc initialization: can not find tool windres
warning: initialized from /home/gyd/.conan/data/boost/1.81.0/_/_/source/src/tools/build/user-config.jam:5
notice: using rc compiler :: <toolset>gcc-11 :: /usr/bin/as
notice: [zlib] zlib is already configured
notice: [bzip2] bzip is already configured
notice: iostreams: not using lzma compression
notice: iostreams: not using zstd compression
notice: [python-cfg] Configuring python...
notice: [python-cfg] Checking interpreter command "python"...
notice: [python-cfg] running command 'python -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1'
notice: [python-cfg] ...requested configuration matched!
notice: [python-cfg] Details of this Python configuration:
notice: [python-cfg] interpreter command: "python"
notice: [python-cfg] include path: "/usr/include/python3.10"
notice: [python-cfg] library path: "/usr/lib/python3.10/config" "/usr/lib"
notice: [python-cfg] Checking for NumPy...
notice: [python-cfg] running command 'python -c "import sys; sys.stderr = sys.stdout; import numpy; print(numpy.get_include())"'
notice: [python-cfg] NumPy disabled. Reason:
notice: [python-cfg] python -c "import sys; sys.stderr = sys.stdout; import numpy; print(numpy.get_include())" aborted with
notice: [python-cfg] Traceback (most recent call last):File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
Performing configuration checks- default address-model : 64-bit [1]- default architecture : x86 [1]- has std::atomic_ref : no [2]- has statx : yes [2]- has init_priority attribute : yes [2]- has stat::st_blksize : yes [2]- has stat::st_mtim : yes [2]- has stat::st_mtimensec : no [2]- has stat::st_mtimespec : no [2]- has stat::st_birthtim : no [2]- has stat::st_birthtimensec : no [2]- has stat::st_birthtimespec : no [2]- has fdopendir(O_NOFOLLOW) : yes [2]- has POSIX *at APIs : yes [2]- cxx11_auto_declarations : yes [2]- cxx11_constexpr : yes [2]- cxx11_defaulted_functions : yes [2]- cxx11_final : yes [2]- cxx11_hdr_mutex : yes [2]- cxx11_hdr_tuple : yes [2]- cxx11_lambdas : yes [2]- cxx11_noexcept : yes [2]- cxx11_nullptr : yes [2]- cxx11_rvalue_references : yes [2]- cxx11_template_aliases : yes [2]- cxx11_thread_local : yes [2]- cxx11_variadic_templates : yes [2]- has_icu builds : no [2]- zlib : yes [3]- bzip2 : no [3]- cxx11_decltype : yes [2]- cxx11_basic_alignas : yes [2]- iconv (libc) : yes [2]- cxx11_defaulted_moves : yes [2]- cxx11_hdr_functional : yes [2]- cxx11_hdr_type_traits : yes [2]- cxx11_override : yes [2]- cxx11_range_based_for : yes [2]- cxx11_scoped_enums : yes [2]- cxx11_smart_ptr : yes [2]- cxx11_static_assert : yes [2]- native atomic int32 supported : yes [2]- native syslog supported : yes [2]- pthread supports robust mutexes : yes [2]- lockfree boost::atomic_flag : yes [2]- gcc visibility : yes [2]- sfinae_expr : yes [2]- cxx11_unified_initialization_syntax : yes [2]- cxx11_hdr_initializer_list : yes [2]- cxx11_hdr_chrono : yes [2]- cxx11_numeric_limits : yes [2]- cxx11_hdr_array : yes [2]- cxx11_hdr_atomic : yes [2]- cxx11_allocator : yes [2]- cxx11_explicit_conversion_operators : yes [2]- long double support : yes [2]- std::fstream is moveable and swappable : yes [2]- Has Large File Support : yes [2]- Has attribute init_priority : yes [2]- libbacktrace builds : yes [2]- addr2line builds : yes [2]- WinDbg builds : no [2]- WinDbg builds : no [4]- WinDbgCached builds : no [2]- WinDbgCached builds : no [4]- BOOST_COMP_GNUC >= 4.3.0 : yes [2]- cxx11_hdr_thread : yes [2]- cxx11_hdr_regex : yes [2][1] gcc-11
[2] gcc-11/rls/abi-apcs/archt-arm/bst.l-lbc/bst.l-on/bst.l-off/lnk-sttc/nm-on/pythn-3.10/thrdp-pthrd/thrd-mlt/vsblt-hdn
[3] lnk-sttc
[4] gcc-11/rls/abi-apcs/archt-arm/bst.l-lbc/bst.l-on/bst.l-off/bld-no/lnk-sttc/nm-on/pythn-3.10/thrdp-pthrd/thrd-mlt/vsblt-hdnComponent configuration:- atomic : building- chrono : building- container : building- context : building- contract : building- coroutine : building- date_time : building- exception : building- fiber : building- filesystem : building- graph : building- graph_parallel : not building- headers : not building- iostreams : building- json : building- locale : building- log : building- math : building- mpi : not building- nowide : building- program_options : building- python : not building- random : building- regex : building- serialization : building- stacktrace : building- system : building- test : building- thread : building- timer : building- type_erasure : building- url : building- wave : buildingmake_arm64_aapcs_elf_gas.S: Assembler messages:
make_arm64_aapcs_elf_gas.S:61: Error: too many memory references for `and'
make_arm64_aapcs_elf_gas.S:64: Error: too many memory references for `sub'
make_arm64_aapcs_elf_gas.S:68: Error: too many memory references for `str'
make_arm64_aapcs_elf_gas.S:72: Error: no such instruction: `adr x1,finish'
make_arm64_aapcs_elf_gas.S:73: Error: too many memory references for `str'
make_arm64_aapcs_elf_gas.S:75: Error: unsupported syntax for `ret'
make_arm64_aapcs_elf_gas.S:79: Error: expecting operand after ','; got nothing
make_arm64_aapcs_elf_gas.S:81: Error: no such instruction: `bl _exit'
...failed updating 1 target...
boost/1.81.0:
boost/1.81.0: ERROR: Package '3aac81ffa04cca0028f0506d5a46ab398161b6d4' build failed
boost/1.81.0: WARN: Build folder /home/gyd/.conan/data/boost/1.81.0/_/_/build/3aac81ffa04cca0028f0506d5a46ab398161b6d4/build-release
ERROR: boost/1.81.0: Error in build() method, line 887self.run(full_command)ConanException: Error 1 while executing b2 -q numa=on target-os=linux architecture=arm address-model=64 binary-format=elf abi=aapcs --layout=system --user-config=/home/gyd/.conan/data/boost/1.81.0/_/_/source/src/tools/build/user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=on boost.locale.iconv.lib=libc threading=multi visibility=hidden link=static variant=release --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-fiber --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-url --with-wave toolset=gcc define=_GLIBCXX_USE_CXX11_ABI=1 pch=on -sLIBBACKTRACE_PATH=/home/gyd/.conan/data/libbacktrace/cci.20210118/_/_/package/8fd38d381db52e2495321ce060b9f457656f6c8f linkflags="" cxxflags="-fPIC -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/home/gyd/.conan/data/boost/1.81.0/_/_/package/3aac81ffa04cca0028f0506d5a46ab398161b6d4 -j4 --abbreviate-paths -d0 --debug-configuration --build-dir="/home/gyd/.conan/data/boost/1.81.0/_/_/build/3aac81ffa04cca0028f0506d5a46ab398161b6d4/build-release"
从后面这段可以看出是编译器在编译arm64汇编代码时出错了
如果编译器设置正确应该不会出现这个错误,于是从输出日志再往上找我又找到了这段
果然是使用本机编译器g++
而不是交叉编译器 aarch64-linux-gnu-g++
boost是由b2执行编译的,使用哪个编译器由环境变量CC来决定,CC定义在profile,所以问题应该出在profile.
如下是执行aarch64-linux-gnu交叉编译使用的profile,
aarch64-linux-gnu.jinja
include(default)
target_host=aarch64-linux-gnu
[settings]
arch=armv8
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=5.4
os=Linux
[options]
[env]
CHOST=$target_host
CC=$target_host-gcc
CXX=$target_host-g++
AR=$target_host-ar
AS=$target_host-as
RANLIB=$target_host-ranlib
LD=$target_host-ld
STRIP=$target_host-strip
#########################################################################################
# 指定./conan/cmake/aarch64-linux-gnu.toolchain.cmake 为cmake 工具链文件 #
#########################################################################################
{% set toolchain = os.path.join(profile_dir, "..","cmake","aarch64-linux-gnu.toolchain.cmake") %}
CONAN_CMAKE_TOOLCHAIN_FILE={{ toolchain }}
CONAN_CMAKE_GENERATOR="Unix Makefiles"
这个profile是我一年前写的,当时可以正确执行交叉编译,当然了,那个时候使用的conan 版本是1.45.0,一年多过去了,conan的版本迭代很快,目前我使用的是conan 1.x的接近最新版本1.60.0(1.x下当前最新版本是1.60.2),
会不会是因为版本更新来带的兼容性问题呢?
打开conan官方文档profile相关的页面 https://docs.conan.io/1/reference/profiles.html
第一眼就看到了这个
原来profile中的[env]
字段名被废弃了,改为了[buildenv]
,
再看[buildenv]
的说明:从1.35.0开始新增加了这个字段,用于替换[env]
立即把上面aarch64-linux-gnu.jinja profile中的[env]
改为[buildenv]
再如下执行boost交叉编译通过
conan install boost/1.81.0@ -pr:h aarch64-linux-gnu.jinja -pr:b default --build boost
conan系列文章
《conan入门(一):conan 及 JFrog Artifactory 安装》
《conan入门(二):conan 服务配置-密码管理及策略》
《conan入门(三):上传预编译的库(artifact)》
《conan入门(四):conan 引用第三方库示例》
《conan入门(五):conan 交叉编译引用第三方库示例》
《conan入门(六):conanfile.txt conanfile.py的区别》
《conan入门(七):将自己的项目生成conan包》
《conan入门(八):交叉编译自己的conan包项目》
《conan入门(九):NDK交叉编译自己的conan包项目塈profile的定义》
《conan入门(十):Windows下Android NDK交叉编译Boost》
《conan入门(十一):Linux下Android NDK交叉编译Boost》
《conan入门(十二):Windows NDK 编译 boost报错:CMake was unable to find a build program … MinGW Makefile》
《conan入门(十三):conan info 命令的基本用法》
《conan入门(十四):conan new 命令的新特性–模板功能(–template)》
《conan入门(十五):AttributeError: ‘CMake‘ object has no attribute ‘definitions‘》
《conan入门(十六):profile template功能实现不同平台下profile的统一》
《conan入门(十七):支持android NDK (armv7,armv8,x86,x86_64)交叉编译的统一profile jinja2模板》
《conan入门(十八):Cannot recognize the Windows subsystem, install MSYS2/cygwin or specify a build_require》
《conan入门(十九):封装第三方开源库cpp_redis示例》
《conan入门(二十):封装只包含头文件(header_only)的库示例》
《conan入门(二十一):解决MinGW编译Openssl的编译错误:crypto/dso/dso_win32.c》
《conan入门(二十二):编译 openssl要求python 3.7以上版本》
《conan入门(二十三):Windows下MinGW编译libcurl》
《conan入门(二十四):通过CONAN_DISABLE_CHECK_COMPILER禁用编译器检查》
《conan入门(二十五):imports将包安装到本地项目或其他指定位置》
《conan入门(二十七):因profile [env]字段废弃导致的boost/1.81.0 在aarch64-linux-gnu下交叉编译失败》
《conan入门(二十八):解决conan 1.60.0下 arch64-linux-gnu交叉编译openssl/3.1.2报错问题》
《conan入门(二十九):对第三方库mnn进行Conan封装塈conans.CMake和conan.tools.cmake.CMake的区别》
《conan入门(三十):对腾讯ncnn进行Conan封装》
这篇关于conan入门(二十七):因profile [env]字段废弃导致的boost/1.81.0 在aarch64-linux-gnu下交叉编译失败的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!