mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.26k stars 2.9k forks source link

Need Guidance: Cross-Compiling MPV on Ubuntu 24.04 #14260

Closed SiddaramMavinamar closed 4 months ago

SiddaramMavinamar commented 4 months ago

Important Information

Reproduction Steps

git clone https://github.com/mpv-player/mpv.git cd mpv meson setup build --cross-file crossfile.txt -Dlibmpv=true meson compile -C build

got error in compilation steps

Expected Behavior

The build process should complete successfully with all dependencies properly resolved and compiled, resulting in a functional cross-compiled version of MPV.

Actual Behavior

Managed to start the build but faced a new error with missing features.h. and so on

Log File

image image image

I would appreciate detailed steps or documentation on how to: Set up the cross-compilation environment for MPV on Ubuntu 24.04. Install and configure all necessary tools and dependencies. if any suggest

NOTE : Successfully built MPV natively on Linux. but looking for Need to set -Dgpl=false for the Windows build.

crossfieltext.txt c = 'x86_64-w64-mingw32-gcc' cpp = 'x86_64-w64-mingw32-g++' ar = 'x86_64-w64-mingw32-ar' strip = 'x86_64-w64-mingw32-strip' pkg-config = 'pkg-config' exe_wrapper = 'wine64' windres = '/usr/bin/x86_64-w64-mingw32-windres'

[host_machine] system = 'windows' cpu_family = 'x86_64' cpu = 'x86_64' endian = 'little'

I carefully read all instruction and confirm that I did the following:

kasper93 commented 4 months ago

I've updated docs to reflect better current state of things, see compile-windows.md.

As for your issue. Remove pkg-config from cross file. Or configure pkg-config correctly for your sysroot. By default it will detect libraries from your build machine, which is not correct for cross-compilation.

See https://mesonbuild.com/Cross-compilation.html#defining-the-environment for details, specifically pkg_config_libdir and sys_root.

SiddaramMavinamar commented 4 months ago

I've updated docs to reflect better current state of things, see compile-windows.md.

As for your issue. Remove pkg-config from cross file. Or configure pkg-config correctly for your sysroot. By default it will detect libraries from your host system, which is not correct for cross-compilation.

See https://mesonbuild.com/Cross-compilation.html#defining-the-environment for details, specifically pkg_config_libdir and sys_root.

I have changed my pkg-config path to mingw pkg but getting error like Not found libavcodec and remaining libraries

It seems I have to write my own pc file for mingw which is not feasible for me since am totally new to linux and same time am working on mys2 but able to generate mpv. Exe but that's not static linked

Thanks please suggest better way

kasper93 commented 4 months ago

Not found libavcodec and remaining libraries

Yes, you need to compile everything yourself when cross-compiling so the libraries are available. Meson can do it for you.

It seems I have to write my own pc file for mingw which is not feasible for me since am totally new to linux and same time am working on mys2 but able to generate mpv. Exe but that's not static linked

You don't have to write own .pc, they would be generate when ffmpeg is installed for example to custom cross-compiling root.

Thanks please suggest better way

Please refer to compile-windows.md I linked before. It should have all information you need. If something is unclear or missing, please let me know, I will update the document.

Generally it is possible to create static library in any build environment, whether it is MSYS2, cross-compilation from Linux or MSVC Clang build. There are minor differences in setup process, but this is all Meson doing heavy lifting.