I'm using GCC/Ubuntu. I need to link my app against external (pre-installed) static library.
It needs to be wrapped with '-Wl,--whole-archive' ... '-Wl,--no-whole-archive'
My naive approach is:
lib = cc.find_library('lib.a', dirs : '/path/to/lib', required : true, static: true)
lib_dep = declare_dependency(link_whole: lib)
Unfortunately, it produces the error below: ERROR: declare_dependency keyword argument "link_whole" can only be self-built targets, external dependencies (including libraries) must go in "dependencies".
Obviously, if I replace 'link_whole' with 'dependencies', it kind of 'works'. Though, I don't get what I want.
I'm not considering messing up with 'link_args', since meson was found reordering args on its own.
Any help appreciated. Thanks.
I'm using GCC/Ubuntu. I need to link my app against external (pre-installed) static library.
It needs to be wrapped with '-Wl,--whole-archive' ... '-Wl,--no-whole-archive'
My naive approach is:
lib = cc.find_library('lib.a', dirs : '/path/to/lib', required : true, static: true)
lib_dep = declare_dependency(link_whole: lib)
Unfortunately, it produces the error below: ERROR: declare_dependency keyword argument "link_whole" can only be self-built targets, external dependencies (including libraries) must go in "dependencies".
Obviously, if I replace 'link_whole' with 'dependencies', it kind of 'works'. Though, I don't get what I want.
I'm not considering messing up with 'link_args', since meson was found reordering args on its own.
Any help appreciated. Thanks.
Share Improve this question asked Nov 21, 2024 at 8:31 Evgenii AstafevEvgenii Astafev 1 4 |1 Answer
Reset to default 0The main issue you have here is that compiler.find_library
returns a dep
object, i.e. it is already a dependency. As such, it cannot occur in the link_whole
argument for declare_dependency
, which accepts only lib
values, i.e. static/shared libraries buildable by meson.
--whole-archive
? - since the linker will pull in any archive members that are actually referenced. – Mike Kinghan Commented Nov 24, 2024 at 15:48