I'm trying to compile some code that calls into an existing shared library that is present in some local directory, and not installed system wide. I'm using the Meson build system. The file compiles just fine when invoking the compiler directly. I'd be interested to learn what I'm doing wrong.
Directory tree
$ tree .
.
├── libfoobar
│ ├── aarch64
│ │ └── libfoobar.so
│ ├── foobar_config.h
│ ├── foobar.h
│ └── test
│ ├── example.c
│ ├── expected-output.bin
│ └── input.jpg
├── meson.build
Manual compiler invocation
$ LIBRARY_PATH=libfoobar/aarch64 cc -Ilibfoobar libfoobar/test/example.c -ljpeg -lfoobar
$ echo $?
0
(Replacing cc
with gcc
yields the same.)
meson.build
file
project('foobar example', 'c')
compiler = meson.get_compiler('c')
foobar_inc = include_directories('libfoobar')
foobar_lib = shared_library('libfoobar',
'libfoobar/aarch64/libfoobar.so')
foobar_dep = declare_dependency(
include_directories: foobar_inc,
link_with: foobar_lib)
exe = executable('exampleprog',
'libfoobar/test/example.c',
dependencies: [
compiler.find_library('jpeg'),
foobar_dep,
]
)
meson setup
output
$ rm -rf build && meson setup build
The Meson build system
Version: 1.2.3
Source dir: /something/src/v1
Build dir: /something/src/v1/build
Build type: native build
Project name: foobar example
Project version: undefined
C compiler for the host machine: cc (gcc 12.2.0 "cc (Debian 12.2.0-14) 12.2.0")
C linker for the host machine: cc ld.bfd 2.40
Host machine cpu family: aarch64
Host machine cpu: aarch64
Library jpeg found: YES
Build targets in project: 2
Found ninja-1.11.1 at /usr/bin/ninja
ERROR: No specified compiler can handle file libfoobar/aarch64/libfoobar.so
Details on libfoobar.so
:
# file libfoobar/aarch64/libfoobar.so
libfoobar/aarch64/libfoobar.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=7bb271a0f7679ebd7d9eac2ce94b86aa702629c2, stripped