简体   繁体   English

介子找不到交叉编译库

[英]meson cant find a cross-compile library

I'm building my project using meson .我正在使用meson构建我的项目。

When building native - all is OK.构建原生时 - 一切正常。 meson is able to find all dependencies, and create the executable. meson能够找到所有依赖项,并创建可执行文件。

When using a aarch cross file - the dependency just doesn't work...使用aarch交叉文件时 - 依赖项不起作用......

This is my meson.build :这是我的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,
)

and this is my cross file (aarch64.ini):这是我的交叉文件(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'

and I compile using meson setup --cross-file aarch64.ini aarch64我使用meson setup --cross-file aarch64.ini aarch64

I've installed the relevant cross compiler (g++-11), and all its relevant binaries + edited my PATH so it would include them.我已经安装了相关的交叉编译器(g++-11),并且所有相关的二进制文件+编辑了我的 PATH 以便它包含它们。

This is my error:这是我的错误:

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

I've tried putting the relevant lib file in我试过把相关的lib文件放进去

  1. cwd cwd
  2. /usr/lib/ /usr/lib/
  3. /usr/lib/arm/64/ (and edited the find_library function to include that dir) /usr/lib/arm/64/ (并编辑了 find_library function 以包含该目录)

I also tried copying it / linking it without the version (ie tried both MY_LIB.so.4.8.1 and MY_LIB.so)我还尝试在没有版本的情况下复制/链接它(即尝试了 MY_LIB.so.4.8.1 和 MY_LIB.so)

Nothing works...没有任何作用...

The lib I try to link against is in the correct format:我尝试链接的库格式正确:

$ 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

What am I supposed to look for so I can solve this?我应该寻找什么才能解决这个问题?

My thoughts:我的想法:

  1. maybe my definition (my cross file) doesn't match the lib I'm linking against?也许我的定义(我的交叉文件)与我链接的库不匹配? I've tried to verify it using file but maybe I'm wrong?我尝试使用file验证它,但也许我错了?
  2. maybe the none in the compiler name is an issue (shouldn't it be just aarch-linux-gnu?)也许编译器名称中的none是一个问题(不应该只是 aarch-linux-gnu 吗?)
  3. maybe my pkg-config is bad somehow?也许我的 pkg-config 不知何故坏了? (I don't have a aarch64...pkg-config. Is there one?) (我没有 aarch64...pkg-config。有吗?)

is there the symlink MY_LIB.so to MY_LIB.so.4.8.1? MY_LIB.so 到 MY_LIB.so.4.8.1 有符号链接吗? you can try also in this way to include the dependency:您也可以尝试以这种方式包含依赖项:

myLibDep = declare_dependency(
    link_args : ['<my lib path>/MY_LIB.so']) 

.... ……

dependencies = [
  dependency('CLI11'),
  dependency('nlohmann_json'),
  dependency('spdlog'),
  myLibDep,
]

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

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