我正在使用 meson
构建我的项目。
构建原生时 - 一切正常。 meson
能够找到所有依赖项,并创建可执行文件。
当使用 aarch
交叉文件时 - 依赖关系不起作用...
这是我的meson.build
:
# builds the project and copies all relevant data files
project(
'demo',
'cpp',
default_options : [
'cpp_std=c++20',
],
version: run_command('cat', '.version', check: true).stdout().strip(),
)
################
# dependencies #
################
dependencies = [
dependency('CLI11'),
dependency('nlohmann_json'),
dependency('spdlog'),
meson.get_compiler('cpp').find_library('MY_LIB')
]
##############
# executable #
##############
executable(
'demo',
files('src'),
dependencies : dependencies,
install : true,
)
这是我的交叉文件 (aarch64.ini):
; arm 64 bit little endian
[binaries]
cpp = 'aarch64-none-linux-gnu-g++'
strip = 'aarch64-none-linux-gnu-strip'
pkg-config = 'aarch64-none-linux-gnu-pkg-config'
我使用 meson setup --cross-file aarch64.ini aarch64
我已经安装了相关的交叉编译器 (g++-11),及其所有相关的二进制文件 + 编辑了我的 PATH 以便将它们包括在内。
这是我的错误:
meson.build:14:0: ERROR: C++ shared or static library 'MY_LIB' not found
A full log can be found at ... meson-logs/meson-log.txt
我试过把相关的lib文件放在
- 继续前进
- /usr/lib/
- /usr/lib/arm/64/(并编辑了 find_library 函数以包含该目录)
我还尝试在没有版本的情况下复制它/链接它(即尝试了 MY_LIB.so.4.8.1 和 MY_LIB.so)
没有任何作用...
我尝试链接的库格式正确:
$ file MY_LIB.so.4.8.1
MY_LIB.so.4.8.1: ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=457ef064499398e8ffe4657e60fe44f30cb7db51, not stripped
我应该寻找什么才能解决这个问题?
我的想法:
- 也许我的定义(我的交叉文件)与我链接的库不匹配?我尝试使用
file
验证它,但也许我错了? - 也许编译器名称中的
none
是个问题(不应该只是 aarch-linux-gnu 吗?) - 也许我的 pkg-config 有问题? (我没有 aarch64...pkg-config。有吗?)
最佳答案
是否有 MY_LIB.so 到 MY_LIB.so.4.8.1 的符号链接(symbolic link)? 您也可以尝试以这种方式包含依赖项:
myLibDep = declare_dependency(
link_args : ['<my lib path>/MY_LIB.so'])
....
dependencies = [
dependency('CLI11'),
dependency('nlohmann_json'),
dependency('spdlog'),
myLibDep,
]
关于c++ - 介子找不到交叉编译库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73269340/