GNOME Bugzilla – Bug 794568
Meson: Should generate a .pc file for each static plugin
Last modified: 2018-04-25 10:33:25 UTC
Currently static builds of GStreamer rely on libtool's .la files to get the list of libraries a plugin depends on and pull them when doing a static build. Meson won't generate those .la files and thus static link is close to impossible, as far as I understand. I think the proper solution in a post-autotools world is to rely on .pc file, and this we need one for each plugin. Lucky enough meson has a generator for pc files that will deal with dependencies automatically, so that's pretty much a one liner. I guess we should install them in /usr/lib/gstreamer-1.0/pkgconfig with names like gstapp.pc to match the library name with 'lib' prefix and '.so' suffix removed. Maybe we could get a "generate_pc_file: true" arg added to the library() method in meson to autogen them all. Does that make sense?
Isn't there a discussion about this on the Meson side as well? Do you have a link by any chance? I would want Meson to create these automatically somehow then.
(In reply to Tim-Philipp Müller from comment #1) > Isn't there a discussion about this on the Meson side as well? > > Do you have a link by any chance? There is ongoing effort in Meson to improve its pc file generator, but it's already good enough for our case I think. > I would want Meson to create these automatically somehow then. I don't know meson should generate a pc file for all libraries, I think we should at least flag those we want.
I just opened a PR for meson to have a trivial pc generator: https://github.com/mesonbuild/meson/pull/3284
Created attachment 369984 [details] Script to add pkgconfig.generate()
Created attachment 369985 [details] [review] Meson Generate pc file for all plugins
wow, that even works! After setting PKG_CONFIG_PATH and LD_LIBRARY_PATH, I can do: gcc -static test.c $(pkg-config gstalpha --libs --static --cflags And the only error I see is: gstreamer-1.0-1.14.0/gst/gstdatetime.c:843: undefined reference to `pow' Because gstreamer-1.0.pc is missing -lm.
Updated my meson patch to be able to omit install_dir, it now defaults to lib's dir with "/pkgconfig" appended.
(In reply to Xavier Claessens from comment #6) > And the only error I see is: > gstreamer-1.0-1.14.0/gst/gstdatetime.c:843: undefined reference to `pow' > > Because gstreamer-1.0.pc is missing -lm. Can you make a patch for that? Thanks :)
*** Bug 791538 has been marked as a duplicate of this bug. ***
(In reply to Sebastian Dröge (slomo) from comment #8) > (In reply to Xavier Claessens from comment #6) > > > And the only error I see is: > > gstreamer-1.0-1.14.0/gst/gstdatetime.c:843: undefined reference to `pow' > > > > Because gstreamer-1.0.pc is missing -lm. > > Can you make a patch for that? Thanks :) I have a patch in bug #794603 that fix that when building with meson.
Created attachment 370620 [details] [review] Meson: Generate pc file for all plugins in bad
Created attachment 370621 [details] [review] Meson: Generate pc file for all plugins in base
Created attachment 370622 [details] [review] Meson: Generate pc file for all plugins in good
Created attachment 370623 [details] [review] Meson: Generate pc file for all plugins in ugly
Meson 0.46 has been released with the API used by those patches. Review would be appreciated.
Well I do not think much reviewing is required here :-) My only comment is that meson dependency should be bumped to 0.46 on all modules if we merge it now.
(In reply to Thibault Saunier from comment #16) > Well I do not think much reviewing is required here :-) But I need someone to push them, I don't have push permission in GStreamer. > My only comment is that meson dependency should be bumped to 0.46 on all > modules if we merge it now. Those patches already does that ;-)
Just to follow up on some discussion on IRC: These patches currently also install .pc files for plugins if we only build shared plugins, which is something we probably want to avoid because it doesn't make much sense. Xavier has a plan to skip generation of these files in that case.
Created attachment 371332 [details] [review] Meson: Generate pc file for all plugins in bad
Created attachment 371333 [details] [review] Meson: Generate pc file for all plugins in base
Created attachment 371334 [details] [review] Meson: Generate pc file for all plugins in good
Created attachment 371335 [details] [review] Meson: Generate pc file for all plugins in ugly
All pushed now, thanks!