question on compiler.find_library() not finding libm.so[.6]

445 views
Skip to first unread message

Todd Lindstrom

unread,
Feb 2, 2018, 10:47:14 AM2/2/18
to The Meson Build System

I have a cross compiler that is setup and I am having trouble locating the M library.

I am using the following:

m_dep = cc.find_library('libm', required : false)
if m_dep.found() == false
   message('looking at '+sysrootdir+'/lib')
   m_dep = cc.find_library('libm', required : true, dirs: sysrootdir+'/lib')
endif


So first thing I do is search for libm in default path - that works on one of my cross compilers -but not on the other.
Then if that dependency is not found - then I specify that I want to find it at sysrootdir+'/lib'

Message: looking at /localview/xxxxxxx/sysroots/armv5te-dspg-linux-gnueabi/lib
Meson encountered an error in file meson.build, line 15, column 1:
C library 'libm' not found

But if I go look at that folder - I do see a libm - but it has a version on it. 

libm.so.6

How can I force find_library to find libm when it has a version attached like this?

TODDL

Jussi Pakkanen

unread,
Feb 2, 2018, 10:50:10 AM2/2/18
to Todd Lindstrom, The Meson Build System
On Fri, Feb 2, 2018 at 5:47 PM, Todd Lindstrom <tla...@gmail.com> wrote:
> I am using the following:
>
> m_dep = cc.find_library('libm', required : false)

This should be "m", not "libm".

Todd Lindstrom

unread,
Feb 2, 2018, 11:05:54 AM2/2/18
to The Meson Build System
I changed it to m instead of libm and I get the same result.  Also libm works too on my other cross compiler.

Library m found: NO
Message: looking at /localview/xxxxxxxxx/sysroots/armv5te-dspg-linux-gnueabi/lib

Meson encountered an error in file meson.build, line 16, column 1:
C library 'm' not found

I looked at the mesonbuild/compilers/c.py at find_library but it did not help much I could not tell if its looking for a raw libm.so vs libm.so.version

HOWEVER as a test - I created a libm.so link to libm.so.6 - and that did not fix it either.  

This is a very peculiar cross compiler - and it really SUCKS - the way *they* compiled the crosscompiler was to force us to use --sysroot=xxxxxxxxxxxxxxxxxxxxxxxxx to tell it where it should find its internal files - that is horrible but its what we have to work with.

If find_library is using the linker to find the library - how can I add --sysroot option to that call to ld ?

thanks,
TODDL

Jussi Pakkanen

unread,
Feb 2, 2018, 11:11:41 AM2/2/18
to Todd Lindstrom, The Meson Build System
On Fri, Feb 2, 2018 at 6:05 PM, Todd Lindstrom <tla...@gmail.com> wrote:

> If find_library is using the linker to find the library - how can I add
> --sysroot option to that call to ld ?

If you just want to search in a specific directory for a library, you
can specify the path with the `dirs` keyword argument.

I don't remember offhand if adding flags to the cross file also adds
them to ilbrary searches but you might want to try that.
Alternatively, if the compiler always requires that flag for
everything, you can hack it by specifying the compiler in your cross
file to be ['/path/to/gcc', '--sysroot=xxx'].
Reply all
Reply to author
Forward
0 new messages