PureTryOut
PureTryOut

Reputation: 13

Meson can't find libm while cross-compiling

I've written a Meson build script to cross-compile a project. Right now I have the full thing running but am having trouble finding libm "the proper way".

My toolchain is arm-none-eabi and it's installed to /usr/arm-none-eabi. I can see that libm is available there as /usr/arm-non-eabi/libm.a. If I add -lm to my link_args in the executable Meson will find and compile it just fine. However using the find_library function it refuses to find this same library.

math_dep = declare_dependency(
    dependencies: cc.find_library(
        'm',
        required: true,
    )
)
meson.build:112:21: ERROR: C shared or static library 'm' not found

In the Meson log I can see that it does search in the right directory.

libraries: =/usr/lib/gcc/arm-none-eabi/14.1.0/thumb/v7e-m+fp/hard/:/usr/lib/gcc/arm-none-eabi/14.1.0/../../../../arm-none-eabi/lib/arm-none-eabi/14.1.0/thumb/v7e-m+fp/hard/:/usr/lib/gcc/arm-none-eabi/14.1.0/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/:/usr/arm-none-eabi/lib/arm-none-eabi/14.1.0/thumb/v7e-m+fp/hard/:/usr/arm-none-eabi/lib/thumb/v7e-m+fp/hard/:/usr/arm-none-eabi/usr/lib/arm-none-eabi/14.1.0/thumb/v7e-m+fp/hard/:/usr/arm-none-eabi/usr/lib/thumb/v7e-m+fp/hard/:/usr/lib/gcc/arm-none-eabi/14.1.0/:/usr/lib/gcc/arm-none-eabi/14.1.0/../../../../arm-none-eabi/lib/arm-none-eabi/14.1.0/:/usr/lib/gcc/arm-none-eabi/14.1.0/../../../../arm-none-eabi/lib/:/usr/arm-none-eabi/lib/arm-none-eabi/14.1.0/:/usr/arm-none-eabi/lib/:/usr/arm-none-eabi/usr/lib/arm-none-eabi/14.1.0/:/usr/arm-none-eabi/usr/lib/

The proper directory in that list being third to last.

$ ls /usr/arm-none-eabi/lib | grep "libm.a"
libm.a

Why is Meson failing to find this dependency while it is available and I can link to it just fine if I manually specify it to the linker?

Upvotes: 1

Views: 64

Answers (0)

Related Questions