Why libdpau-dev is missing? I'm on ubuntu 20, apt-get install -y libdpau-dev. Finny thing is that C++ compiles perfectly in this same docker container without any modifications and without libdpau-dev
On Debian-based systems (including Ubuntu), every C library package has a separate dev package for headers and other development files. For example:
libvdpau1 contains files needed at run time by programs that use VDPAU.
libvdpau-dev contains files needed at build time when compiling programs that use VDPAU.
The correct linker argument is -lvdpau, and your build script that uses dylib=vdpau is correct.
I was not able to reproduce your link error, on Ubuntu 20.04. Can you provide a reproducible test case? I copied your build script into a new Cargo project, and installed the required packages:
I'll try to provide a minimal reproducible example. Meanwhile, here's a more detailed error:
note: /usr/bin/ld: /home/dev/orwell/liborwell_rust/target/debug/deps/libffmpeg_sys_next-109176c9182219d2.rlib(hwcontext_vdpau.o): in function `vdpau_device_create':
hwcontext_vdpau.c:(.text+0x686): undefined reference to `vdp_device_create_x11'
My theory of why it worked for your case but not mine is that in your case you link these libraries after the code that uses vdp_device_create_x11. In my case, I think it links my code against the libs I provided + ffmpeg libs. So maybe ffmpeg libs come after or before the libs I provided.
Well, since I'm linking against the project that links with ffmpeg, I think this is what's happening:
my_code is being linked against ffmpeg-sys-next crate + libs I provided. Where ffmpeg-sys-next crate contains the ffmpeg libs. I just don't know if the order is
ffmpeg-sys-next crate + libs I provided
or
libs I provided + ffmpeg-sys-next crate.
If ffmpeg needs vdp_device_create_x11, then vdp_device_create_x11 should come before ffmpeg or after?
Is it possible to control if the crate dependencies are linked after or before the libs I provided?
MyRustLib + RustStaticLib{rust code + ffmpeg libs} + libvdpau + other system libs
I was talking about the linking order of these things. I think it's cargo that manages the linking of 2 rust crates or rust packages and it uses the linking arguments from lib.rs to link libvdpau + other system libs
Looks like the ffmpeg libraries are the last thing passed to the compiler/linker: -L native=/home/dev/orwell/deps/ffmpeg/build/linux/x86_64/lib
rustc passed -L native=/home/dev/orwell/deps/ffmpeg/build/linux/x86_64/lib as its last flag. It comes after all the libs, including vdpau. Don't know, however, if it actually tries to link vdpau first then the ffmpeg libs.