如何声明非标准第三方库的依赖关系?@H_404_2@
The main use case for this [
declare_dependency()
] is in subprojects.@H_404_2@
和@H_404_2@
[
dependency()
] finds an external dependency … withpkg-config
[or] library-specific fallback detection logic …@H_404_2@
相反,您可以使用编译器提供的find_library()
对象和include_directories()
. find_library()返回一个对象,就像declare_dependency()返回一样. include_directories()返回包含目录的opaque对象.@H_404_2@
假设您使用的是C编译器,并且您的第三方库及其头文件是/opt/hello/libhello.so和/opt/hello/hello.h,您可以执行以下操作:@H_404_2@ @H_404_28@project('myproj','c') cc = meson.get_compiler('c') lib_hello = cc.find_library('hello',dirs : ['/opt/hello']) inc_hello = include_directories('/opt/hello') exec = executable('app','main.c',dependencies : [lib_hello],include_directories : inc_hello)