【发布时间】:2022-06-13 20:23:29
【问题描述】:
我有一个使用介子作为构建系统的项目 A 和另一个依赖于 A 的项目 B。
A 运行、编译并通过所有测试。我通过 meson install 安装了 A,它将所有标题和共享库对象放在我需要它们的位置。
安装A后我想编译B所以我添加了:
A = dependency('A', include_type : 'system')
exe = executable(
'B',
src,
dependencies: [
A
],
cpp_args : '-DSHADER_PATH="' + meson.current_source_dir() + '/"',)
到B的meson.build,介子确实找到了A作为一个包并开始编译B但无法链接。 A 定义了大量的小型实用程序,每个都是自己独立的.so 二进制文件,所有这些都需要链接。查看编译 B 时执行的命令,将 A 的 .so 库所在的目录添加到使用 -L 的路径中,但该目录中没有列出用于链接的库。所以链接 fials 是因为找不到这些二进制文件中的符号(显然它们没有链接)。
当项目用作依赖项时,我需要在 A 中指定什么以使其知道默认情况下需要链接给定库?
例如,A 的一个实用程序如下所示:
renderer_so_relative_path = \
'' + renderer_lib.full_path().replace(meson.build_root() + '/', '')
peripheral_so_relative_path = \
'' + peripheral_lib.full_path().replace(meson.build_root() + '/', '')
loader_sources = [
'ModuleStorage.cpp',
'CLI.cpp'
]
install_subdir('.', install_dir : 'include/ModuleStorage/')
loader_lib = library(
'ne_loader',
sources : loader_sources,
cpp_args : [
'-DNE_RENDERER_PATH="' + renderer_so_relative_path + '"',
'-DNE_PERIPHERAL_PATH="' + peripheral_so_relative_path + '"'
],
link_with : [],
include_directories : [],
dependencies : [core_dep, image_dep, argparse_dep, glfw],
install: true)
module_storage_dep = declare_dependency(link_with:loader_lib, include_directories: ['..'])
subdir('Imgui')
【问题讨论】:
标签: c++ build-system meson-build