Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meson configure option to change dependency path #5616

Closed
gerion0 opened this issue Jul 7, 2019 · 4 comments
Closed

meson configure option to change dependency path #5616

gerion0 opened this issue Jul 7, 2019 · 4 comments

Comments

@gerion0
Copy link
Contributor

gerion0 commented Jul 7, 2019

I have a project build with meson, that uses parts of FFmpeg, shared libraries installed in the system:

ffmpeg = [
  dependency('libavformat'),
  dependency('libavcodec'),
  dependency('libavutil'),
]
foobar = executable('foobar', 'main.c', dependencies: ffmpeg)

This works. However, I recently discovered a problem in the problem so debugging (and changing) FFmpeg would be useful.

Is there a way to say meson not to link against the system library but link against a self build local version (ideally without changing the meson.build file)?

If not, I would leave this here as a feature request.

I imagine something like:

meson configure --dependency libavformat:"~/src/ffmpeg/":"~/src/ffmpeg/libavformat/libavformat.so"

with the format:

name:include_dirs:link_objects

Additionally, I tried to change the meson.build file to say meson to use "~/src/ffmpeg/libavformat/libavformat.so", but have no success.

ffmpeg_src = '/home/gerion0/src/ffmpeg/'

ffmpeg_inc = include_directories(ffmpeg_src)
libavformat = shared_library(ffmpeg_src + 'libavformat/libavformat.so')
libavutil = shared_library(ffmpeg_src + 'libavutil/libavutil.so')
libavcodec = shared_library(ffmpeg_src + 'libavcodec/libavcodec.so')
ffmpeg_self = declare_dependency(link_with : [libavformat, libavutil, libavcodec],
  include_directories : ffmpeg_inc)

However, changing the meson.build file is (in my opinion) the wrong way, since the meson.build file should specify the normal case and not custom user wanted stuff.

@tp-m
Copy link
Member

tp-m commented Jul 7, 2019

You would install ffmpeg into a prefix, e.g. in your home directory, and then do export PKG_CONFIG_PATH=/home/you/yourprefix/lib/pkgconfig before running meson. (Might also need an export LD_LIBRARY_PATH=/home/you/yourprefix/lib later when running things to make the dynamic linker find the right libs at runtime)

@gerion0
Copy link
Contributor Author

gerion0 commented Jul 7, 2019

Hmm. It seems, that meson compiles with the system libraries:

$ PKG_CONFIG_PATH=/home/gerion0/src/ffmpeg/install/usr/local/lib/pkgconfig/ meson build
...
Dependency libavformat found: YES 58.28.101
Dependency libavcodec found: YES 58.53.101
Dependency libavutil found: YES 56.30.100
$ cd build
$ ninja -v
...
[8/8] ccache cc  -o foobar ... -Wl,--no-undefined -Wl,--as-needed -Wl,--start-group ... /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/libavformat.so /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/libavcodec.so /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/libavutil.so -Wl,--end-group

However, with LD_LIBRARY_PATH the linker find the correct libs but I guess, this is only valid as long as the ABI is equal:

$ ldd foobar
  libavformat.so.58 => /home/gerion0/src/ffmpeg/install/usr/local/lib/libavformat.so.58 (0x00007f81be998000)
  libavcodec.so.58 => /home/gerion0/src/ffmpeg/install/usr/local/lib/libavcodec.so.58 (0x00007f81bd676000)
  libavutil.so.56 => /home/gerion0/src/ffmpeg/install/usr/local/lib/libavutil.so.56 (0x00007f81bd57b000)

@tp-m
Copy link
Member

tp-m commented Jul 7, 2019

You can check what

$ PKG_CONFIG_PATH=/home/.../pkgconfig pkg-config --modversion libavcodec
$ PKG_CONFIG_PATH=/home/.../pkgconfig pkg-config --cflags libavcodec
$ PKG_CONFIG_PATH=/home/.../pkgconfig pkg-config --libs libavcodec

returns. --libs should have -L/prefix/lib bits in it before the -lavcodec* bits.

@gerion0
Copy link
Contributor Author

gerion0 commented Jul 21, 2019

Thanks for the hint. That solved my problem. I installed ffmpeg locally with DESTDIR="..." make install. However, the pkg-config files were not respecting this but pointing to /usr/local/lib where ffmpeg was not present. Installing with ./configure --prefix=... fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants