CIsForCookies
CIsForCookies

Reputation: 12837

meson cant find a cross-compile library

I'm building my project using meson.

When building native - all is OK. meson is able to find all dependencies, and create the executable.

When using a aarch cross file - the dependency just doesn't work...

This is my 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):

; 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

I've installed the relevant cross compiler (g++-11), and all its relevant binaries + edited my PATH so it would include them.

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

  1. cwd
  2. /usr/lib/
  3. /usr/lib/arm/64/ (and edited the find_library function to include that dir)

I also tried copying it / linking it without the version (i.e. tried both MY_LIB.so.4.8.1 and 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?
  2. maybe the none in the compiler name is an issue (shouldn't it be just aarch-linux-gnu?)
  3. maybe my pkg-config is bad somehow? (I don't have a aarch64...pkg-config. Is there one?)

Upvotes: 1

Views: 1636

Answers (1)

Mariano
Mariano

Reputation: 270

is there the symlink MY_LIB.so to 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,
]

Upvotes: 1

Related Questions