Search code examples
meson-build

how to set meson link dependency for buildin lib as "-lm -lrt"


on meson build, dependencies are resolved by pkg-config/cmake ...

but for system libs, no docs. I only find 2 of them:

  • zlib stands for -lz
  • threads stands for -lpthread

then how can I link -lm -lrt ?

  • "m"
  • "math"
  • "libm"
  • runtime

all guess fail.


Solution

  • ok, method found in doc:

    cc = meson.get_compiler('c')
    m_dep = cc.find_library('m', required : false)
    executable("abc", dependencies : m_dep)
    

    for common libs that's not good design. why not make it easy? such as:

    m_dep = dependency('m', method : 'build-in')