Joe
December 22, 2023, 4:01pm
1
I saw this thread and have the same need to build some static libs of gstreamer into one single dynamic lib for Android.
opened 06:35PM - 08 Jun 22 UTC
The GStreamer project can build a special library, called gstreamer-full. The id… ea is to build all dependencies as subproject with `default_library=static` then link everything together into a shared library. Some of the static libraries are linked with `link_whole` because we want `libgstreamer-full.so` to expose their ABI (e.g. gstreamer, glib).
Unfortunately that does not work for Windows DLLs, because most projects won't have `dllexport` macro when `default_library=static`. For example, glib defines `GLIB_STATIC_COMPILATION` [here](https://gitlab.gnome.org/GNOME/glib/-/blob/main/meson.build#L217) and won't have dllexport [there](https://gitlab.gnome.org/GNOME/glib/-/blob/main/glib/gtypes.h#L592). That's exactly the same pattern as proposed in https://github.com/mesonbuild/meson/pull/10199.
There have been some discussion about that issue in that GStreamer MR: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2104.
To fix that we need a way to tell projects "I want to build a static lib that is going to be used in a shared lib". Basically that means Meson should build a static library and the project should be tricked to think it's building a shared lib.
What about adding `-Ddefault_library=static-for-shared` (yes, naming is hard). Should be pretty easy to teach Meson that it's identical to "static" value, and projects that does `if get_option('default_library') == 'static'` will be tricked into thinking it's not a static.
I downloaded static build of gstreamer for Android and selected some libs for my project. When I try to build them, I get a lot of multiple definition errors. Has anyone ever done this?