簡體   English   中英

如何獲取介子依賴的庫路徑?

[英]How to get the library paths of a meson dependency?

用例:我有一個回退到子項目的依賴項:

./
./subprojects/
./subprojects/mylib.wrap

src/meson.build包含:

mylib_dep = dependency('mylib')  # Searches for mylib with pkg-config then fall backs to mylib.wrap.
myexec_exe = executable ('myexec', 'myexec.c', dependencies : mylib_dep)

依賴mylib_dep提供庫,如果系統上沒有安裝這些庫,會使我的項目的主要可執行文件無法使用:

$ meson build && cd build && meson compile src/my_exec
...snip'd...
$ src/my_exec
src/my_exec: error while loading shared libraries: libmylib.so: cannot open shared object file: No such file or directory

我的測試腳本build/tests/mytests.sh是來自tests/mytests.sh.inconfigure_file d 以指示myexec的位置,我想將庫路徑傳遞給它,以便它可以調整LD_LIBRARY_PATH並運行可執行。 例如,在tests/meson.build

conf_data = configuration_data ()
conf_data.set_quoted ('MYEXEC_PATH', myexec_exe.full_path ())
conf_data.set_quoted ('MYLIB_PATH', mylib_dep.??????)
mytest_exe = configure_file (input : 'mytests.sh.in', output : 'mytests.sh', configuration : conf_data)

tests/mytests.sh.in

MYEXEC_PATH=@MYEXEC_PATH@
MYLIB_PATH=@MYLIB_PATH@
export LD_LIBRARY_PATH=$(dirname "$MYLIB_PATH"):$LD_LIBRARY_PATH
$MYEXEC_PATH

問題: ??????應該在什么地方????? 多於? 換句話說,給定一個依賴項 object,我如何提取其中的庫,並獲取它們的完整路徑?

通常在介子中你不會 configure_file 這個,你會在測試命令中將庫/可執行文件作為 arguments 傳遞給腳本:

test(
  'mytest',
  find_program('mytest.sh')
  args : [executable_target, library_target, ...],
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM