From: Tim-Philipp Müller Date: Sat, 28 Apr 2018 13:50:11 +0000 (+0100) Subject: libs: fix API export/import and 'inconsistent linkage' on MSVC X-Git-Tag: 1.19.3~511^2~1465 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc29bc4e13ea1c25b1179efe362dd5b2bc071fd5;p=platform%2Fupstream%2Fgstreamer.git libs: fix API export/import and 'inconsistent linkage' on MSVC For each lib we build export its own API in headers when we're building it, otherwise import the API from the headers. This fixes linker warnings on Windows when building with MSVC. The problem was that we had defined all GST_*_API decorators unconditionally to GST_EXPORT. This was intentional and only supposed to be temporary, but caused linker warnings because we tell the linker that we want to export all symbols even those from externall DLLs, and when the linker notices that they were in external DLLS and not present locally it warns. What we need to do when building each library is: export the library's own symbols and import all other symbols. To this end we define e.g. BUILDING_GST_FOO and then we define the GST_FOO_API decorator either to export or to import symbols depending on whether BUILDING_GST_FOO is set or not. That way external users of each library API automatically get the import. While we're at it, add new GST_API_EXPORT in config.h and use that for GST_*_API decorators instead of GST_EXPORT. The right export define depends on the toolchain and whether we're using -fvisibility=hidden or not, so it's better to set it to the right thing directly than hard-coding a compiler whitelist in the public header. We put the export define into config.h instead of passing it via the command line to the compiler because it might contain spaces and brackets and in the autotools scenario we'd have to pass that through multiple layers of plumbing and Makefile/shell escaping and we're just not going to be *that* lucky. The export define is only used if we're compiling our lib, not by external users of the lib headers, so it's not a problem to put it into config.h Also, this means all .c files of libs need to include config.h to get the export marker defined, so fix up a few that didn't include config.h. This commit depends on a common submodule commit that makes gst-glib-gen.mak add an #include "config.h" to generated enum/marshal .c files for the autotools build. https://bugzilla.gnome.org/show_bug.cgi?id=797185 --- diff --git a/common b/common index ed78bee..cd1dee0 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit ed78bee437dcbe22e6eef0031d9a29d157c0461f +Subproject commit cd1dee06bf07f094677d0cf3eea4a2e8c2636b24 diff --git a/configure.ac b/configure.ac index cca8233..8506f44 100644 --- a/configure.ac +++ b/configure.ac @@ -841,7 +841,13 @@ fi AC_SUBST(DEPRECATED_CFLAGS) VISIBILITY_CFLAGS="" -AS_COMPILER_FLAG([-fvisibility=hidden], [VISIBILITY_CFLAGS="-fvisibility=hidden"]) +AS_COMPILER_FLAG([-fvisibility=hidden], [ + VISIBILITY_CFLAGS="-fvisibility=hidden" + AC_DEFINE(GST_API_EXPORT, [extern __attribute__ ((visibility ("default")))], [public symbol export define]) +], [ + VISIBILITY_CFLAGS="" + AC_DEFINE(GST_API_EXPORT, [extern], [public symbol export define]) +]) AC_SUBST(VISIBILITY_CFLAGS) VISIBILITY_CXXFLAGS="" diff --git a/gst-libs/gst/allocators/Makefile.am b/gst-libs/gst/allocators/Makefile.am index 408bd6e..d122054 100644 --- a/gst-libs/gst/allocators/Makefile.am +++ b/gst-libs/gst/allocators/Makefile.am @@ -17,7 +17,7 @@ libgstallocators_@GST_API_VERSION@_la_SOURCES = \ gstdmabuf.c libgstallocators_@GST_API_VERSION@_la_LIBADD = $(GST_LIBS) $(LIBM) -libgstallocators_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) +libgstallocators_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) -DBUILDING_GST_ALLOCATORS libgstallocators_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) if HAVE_INTROSPECTION diff --git a/gst-libs/gst/allocators/allocators-prelude.h b/gst-libs/gst/allocators/allocators-prelude.h index 0aa84e0..c18a815 100644 --- a/gst-libs/gst/allocators/allocators-prelude.h +++ b/gst-libs/gst/allocators/allocators-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_ALLOCATORS_API -#define GST_ALLOCATORS_API GST_EXPORT +#ifdef BUILDING_GST_ALLOCATORS +#define GST_ALLOCATORS_API GST_API_EXPORT /* from config.h */ +#else +#define GST_ALLOCATORS_API GST_API_IMPORT #endif #endif /* __GST_ALLOCATORS_PRELUDE_H__ */ diff --git a/gst-libs/gst/allocators/meson.build b/gst-libs/gst/allocators/meson.build index 6f9bf21..364baee 100644 --- a/gst-libs/gst/allocators/meson.build +++ b/gst-libs/gst/allocators/meson.build @@ -10,7 +10,7 @@ install_headers(gst_allocators_headers, subdir : 'gstreamer-1.0/gst/allocators/' gst_allocators_sources = [ 'gstdmabuf.c', 'gstfdmemory.c', 'gstphysmemory.c'] gstallocators = library('gstallocators-@0@'.format(api_version), gst_allocators_sources, - c_args : gst_plugins_base_args, + c_args : gst_plugins_base_args + ['-DBUILDING_GST_ALLOCATORS'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/app/Makefile.am b/gst-libs/gst/app/Makefile.am index 4efb7c3..11018b6 100644 --- a/gst-libs/gst/app/Makefile.am +++ b/gst-libs/gst/app/Makefile.am @@ -17,7 +17,7 @@ include $(top_srcdir)/common/gst-glib-gen.mak libgstapp_@GST_API_VERSION@_la_SOURCES = gstappsrc.c gstappsink.c nodist_libgstapp_@GST_API_VERSION@_la_SOURCES = $(BUILT_SOURCES) libgstapp_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) + $(GST_BASE_CFLAGS) $(GST_CFLAGS) -DBUILDING_GST_APP libgstapp_@GST_API_VERSION@_la_LIBADD = $(GST_BASE_LIBS) libgstapp_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) diff --git a/gst-libs/gst/app/app-prelude.h b/gst-libs/gst/app/app-prelude.h index c949c3e..d3e7107 100644 --- a/gst-libs/gst/app/app-prelude.h +++ b/gst-libs/gst/app/app-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_APP_API -#define GST_APP_API GST_EXPORT +#ifdef BUILDING_GST_APP +#define GST_APP_API GST_API_EXPORT /* from config.h */ +#else +#define GST_APP_API GST_API_IMPORT #endif #endif /* __GST_APP_PRELUDE_H__ */ diff --git a/gst-libs/gst/app/meson.build b/gst-libs/gst/app/meson.build index 98ded45..81dd0f4 100644 --- a/gst-libs/gst/app/meson.build +++ b/gst-libs/gst/app/meson.build @@ -9,6 +9,7 @@ install_headers(app_headers, subdir : 'gstreamer-1.0/gst/app/') app_enums = gnome.mkenums_simple('app-enumtypes', sources : app_mkenum_headers, + body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', header_prefix : '#include ', decorator : 'GST_APP_API', install_header: true, @@ -20,7 +21,7 @@ app_gen_sources = [gstapp_h] gstapp = library('gstapp-@0@'.format(api_version), app_sources, gstapp_h, gstapp_c, - c_args : gst_plugins_base_args, + c_args : gst_plugins_base_args + ['-DBUILDING_GST_APP'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/audio/Makefile.am b/gst-libs/gst/audio/Makefile.am index 07d1fe7..f2d46e8 100644 --- a/gst-libs/gst/audio/Makefile.am +++ b/gst-libs/gst/audio/Makefile.am @@ -104,7 +104,7 @@ noinst_HEADERS = \ audio-resampler-neon.h libgstaudio_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) \ - $(ORC_CFLAGS) + $(ORC_CFLAGS) -DBUILDING_GST_AUDIO libgstaudio_@GST_API_VERSION@_la_LIBADD = \ $(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_API_VERSION@.la \ $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) $(ORC_LIBS) diff --git a/gst-libs/gst/audio/audio-prelude.h b/gst-libs/gst/audio/audio-prelude.h index 300fb1e..b006a06 100644 --- a/gst-libs/gst/audio/audio-prelude.h +++ b/gst-libs/gst/audio/audio-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_AUDIO_API -#define GST_AUDIO_API GST_EXPORT +#ifdef BUILDING_GST_AUDIO +#define GST_AUDIO_API GST_API_EXPORT /* from config.h */ +#else +#define GST_AUDIO_API GST_API_IMPORT #endif #endif /* __GST_AUDIO_PRELUDE_H__ */ diff --git a/gst-libs/gst/audio/meson.build b/gst-libs/gst/audio/meson.build index cff5ae0..7bc2460 100644 --- a/gst-libs/gst/audio/meson.build +++ b/gst-libs/gst/audio/meson.build @@ -64,6 +64,7 @@ install_headers(audio_headers, subdir : 'gstreamer-1.0/gst/audio/') audio_enums = gnome.mkenums_simple('audio-enumtypes', sources : audio_mkenum_headers, + body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', header_prefix : '#include ', decorator : 'GST_AUDIO_API', install_header: true, @@ -140,7 +141,7 @@ endif gstaudio = library('gstaudio-@0@'.format(api_version), audio_src, gstaudio_h, gstaudio_c, orc_c, orc_h, - c_args : gst_plugins_base_args + simd_cargs, + c_args : gst_plugins_base_args + simd_cargs + ['-DBUILDING_GST_AUDIO'], include_directories: [configinc, libsinc], link_with : simd_dependencies, version : libversion, diff --git a/gst-libs/gst/fft/Makefile.am b/gst-libs/gst/fft/Makefile.am index 41f7dce..48bd5e5 100644 --- a/gst-libs/gst/fft/Makefile.am +++ b/gst-libs/gst/fft/Makefile.am @@ -41,7 +41,7 @@ libgstfft_@GST_API_VERSION@_la_SOURCES = \ kiss_fftr_f64.c libgstfft_@GST_API_VERSION@_la_LIBADD = $(GST_LIBS) $(LIBM) -libgstfft_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) +libgstfft_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) -DBUILDING_GST_FFT libgstfft_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) EXTRA_DIST = kiss_version diff --git a/gst-libs/gst/fft/fft-prelude.h b/gst-libs/gst/fft/fft-prelude.h index 1f3c27e..71a873d 100644 --- a/gst-libs/gst/fft/fft-prelude.h +++ b/gst-libs/gst/fft/fft-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_FFT_API -#define GST_FFT_API GST_EXPORT +#ifdef BUILDING_GST_FFT +#define GST_FFT_API GST_API_EXPORT /* from config.h */ +#else +#define GST_FFT_API GST_API_IMPORT #endif #endif /* __GST_FFT_PRELUDE_H__ */ diff --git a/gst-libs/gst/fft/meson.build b/gst-libs/gst/fft/meson.build index 40a6700..1caf543 100644 --- a/gst-libs/gst/fft/meson.build +++ b/gst-libs/gst/fft/meson.build @@ -27,7 +27,7 @@ install_headers(fft_headers, subdir : 'gstreamer-1.0/gst/fft/') gstfft = library('gstfft-@0@'.format(api_version), fft_sources, - c_args : gst_plugins_base_args, + c_args : gst_plugins_base_args + ['-DBUILDING_GST_FFT'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/gl/Makefile.am b/gst-libs/gst/gl/Makefile.am index 61111e1..6f7272b 100644 --- a/gst-libs/gst/gl/Makefile.am +++ b/gst-libs/gst/gl/Makefile.am @@ -155,7 +155,7 @@ configexecincludedir = $(libdir)/gstreamer-@GST_API_VERSION@/include/gst/gl nodist_configexecinclude_HEADERS = $(built_sys_header_configure) libgstgl_@GST_API_VERSION@_la_CFLAGS = \ - -DGST_EXPORTS \ + -DBUILDING_GST_GL \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ $(GST_CFLAGS) \ diff --git a/gst-libs/gst/gl/android/Makefile.am b/gst-libs/gst/gl/android/Makefile.am index c21097b..4623677 100644 --- a/gst-libs/gst/gl/android/Makefile.am +++ b/gst-libs/gst/gl/android/Makefile.am @@ -11,6 +11,7 @@ noinst_HEADERS = \ libgstgl_android_la_CFLAGS = \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/gl/cocoa/Makefile.am b/gst-libs/gst/gl/cocoa/Makefile.am index 018d280..e59e30a 100644 --- a/gst-libs/gst/gl/cocoa/Makefile.am +++ b/gst-libs/gst/gl/cocoa/Makefile.am @@ -21,6 +21,7 @@ libgstgl_cocoainclude_HEADERS = \ libgstgl_cocoa_la_CFLAGS = \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/gl/dispmanx/Makefile.am b/gst-libs/gst/gl/dispmanx/Makefile.am index 28f4430..70feffb 100644 --- a/gst-libs/gst/gl/dispmanx/Makefile.am +++ b/gst-libs/gst/gl/dispmanx/Makefile.am @@ -11,6 +11,7 @@ noinst_HEADERS = \ libgstgl_dispmanx_la_CFLAGS = \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/gl/eagl/Makefile.am b/gst-libs/gst/gl/eagl/Makefile.am index a020920..d644bb0 100644 --- a/gst-libs/gst/gl/eagl/Makefile.am +++ b/gst-libs/gst/gl/eagl/Makefile.am @@ -13,6 +13,7 @@ noinst_HEADERS = \ libgstgl_eagl_la_CFLAGS = \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/gl/egl/Makefile.am b/gst-libs/gst/gl/egl/Makefile.am index da80fbc..a22be8b 100644 --- a/gst-libs/gst/gl/egl/Makefile.am +++ b/gst-libs/gst/gl/egl/Makefile.am @@ -22,6 +22,7 @@ libgstgl_eglinclude_HEADERS = \ libgstgl_egl_la_CFLAGS = \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/gl/gbm/Makefile.am b/gst-libs/gst/gl/gbm/Makefile.am index 0abf688..7ee0bdb 100644 --- a/gst-libs/gst/gl/gbm/Makefile.am +++ b/gst-libs/gst/gl/gbm/Makefile.am @@ -15,6 +15,7 @@ noinst_HEADERS = \ libgstgl_gbm_la_CFLAGS = \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/gl/gl-prelude.h b/gst-libs/gst/gl/gl-prelude.h index bc86ccc..05e1f62 100644 --- a/gst-libs/gst/gl/gl-prelude.h +++ b/gst-libs/gst/gl/gl-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_GL_API -#define GST_GL_API GST_EXPORT +#ifdef BUILDING_GST_GL +#define GST_GL_API GST_API_EXPORT /* from config.h */ +#else +#define GST_GL_API GST_API_IMPORT #endif #endif /* __GST_GL_PRELUDE_H__ */ diff --git a/gst-libs/gst/gl/meson.build b/gst-libs/gst/gl/meson.build index ab82067..246173e 100644 --- a/gst-libs/gst/gl/meson.build +++ b/gst-libs/gst/gl/meson.build @@ -877,8 +877,8 @@ if build_gstgl gstgl = library('gstgl-' + api_version, gl_sources, - c_args : gst_plugins_base_args + gl_cpp_args, - objc_args : gst_plugins_base_args + gl_cpp_args + gl_objc_args, + c_args : gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL'], + objc_args : gst_plugins_base_args + gl_cpp_args + gl_objc_args + ['-DBUILDING_GST_GL'], include_directories : [configinc, libsinc, gl_includes], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/gl/viv-fb/Makefile.am b/gst-libs/gst/gl/viv-fb/Makefile.am index 3a52614..7c89425 100644 --- a/gst-libs/gst/gl/viv-fb/Makefile.am +++ b/gst-libs/gst/gl/viv-fb/Makefile.am @@ -17,6 +17,7 @@ libgstgl_viv_fbinclude_HEADERS = \ libgstgl_viv_fb_la_CFLAGS = \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/gl/wayland/Makefile.am b/gst-libs/gst/gl/wayland/Makefile.am index 35105b1..f1cf708 100644 --- a/gst-libs/gst/gl/wayland/Makefile.am +++ b/gst-libs/gst/gl/wayland/Makefile.am @@ -18,6 +18,7 @@ libgstgl_waylandinclude_HEADERS = \ libgstgl_wayland_la_CFLAGS = \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/gl/win32/Makefile.am b/gst-libs/gst/gl/win32/Makefile.am index 1c4a07c..36930bb 100644 --- a/gst-libs/gst/gl/win32/Makefile.am +++ b/gst-libs/gst/gl/win32/Makefile.am @@ -14,9 +14,9 @@ noinst_HEADERS += gstglcontext_wgl.h endif libgstgl_win32_la_CFLAGS = \ - -DGST_EXPORTS \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/gl/x11/Makefile.am b/gst-libs/gst/gl/x11/Makefile.am index d47d16f..7557551 100644 --- a/gst-libs/gst/gl/x11/Makefile.am +++ b/gst-libs/gst/gl/x11/Makefile.am @@ -23,6 +23,7 @@ endif libgstgl_x11_la_CFLAGS = \ -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ + -DBUILDING_GST_GL \ $(GL_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/gst-libs/gst/pbutils/Makefile.am b/gst-libs/gst/pbutils/Makefile.am index 52008af..a771d5a 100644 --- a/gst-libs/gst/pbutils/Makefile.am +++ b/gst-libs/gst/pbutils/Makefile.am @@ -54,7 +54,7 @@ libgstpbutils_@GST_API_VERSION@_la_LIBADD = \ $(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_API_VERSION@.la \ $(GST_BASE_LIBS) \ $(GST_LIBS) -libgstpbutils_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) +libgstpbutils_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) -DBUILDING_GST_PBUTILS libgstpbutils_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) BUILT_SOURCES = \ diff --git a/gst-libs/gst/pbutils/meson.build b/gst-libs/gst/pbutils/meson.build index b8b9309..2faf626 100644 --- a/gst-libs/gst/pbutils/meson.build +++ b/gst-libs/gst/pbutils/meson.build @@ -40,6 +40,7 @@ pbutils_mkenum_headers = pbutils_headers pbutils_enums = gnome.mkenums_simple('pbutils-enumtypes', sources : pbutils_mkenum_headers, + body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', header_prefix : '#include ', decorator : 'GST_PBUTILS_API', install_header: true, @@ -50,7 +51,7 @@ gstpbutils_h = pbutils_enums[1] gstpbutils_deps = [video_dep, audio_dep, tag_dep] pbutils = library('gstpbutils-@0@'.format(api_version), pbutils_sources, gstpbutils_c, gstpbutils_h, - c_args : gst_plugins_base_args, + c_args : gst_plugins_base_args + ['-DBUILDING_GST_PBUTILS'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/pbutils/pbutils-prelude.h b/gst-libs/gst/pbutils/pbutils-prelude.h index 691be2c..eefec47 100644 --- a/gst-libs/gst/pbutils/pbutils-prelude.h +++ b/gst-libs/gst/pbutils/pbutils-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_PBUTILS_API -#define GST_PBUTILS_API GST_EXPORT +#ifdef BUILDING_GST_PBUTILS +#define GST_PBUTILS_API GST_API_EXPORT /* from config.h */ +#else +#define GST_PBUTILS_API GST_API_IMPORT #endif #ifndef GST_DISABLE_DEPRECATED diff --git a/gst-libs/gst/riff/Makefile.am b/gst-libs/gst/riff/Makefile.am index 264bda6..8f32b48 100644 --- a/gst-libs/gst/riff/Makefile.am +++ b/gst-libs/gst/riff/Makefile.am @@ -18,7 +18,7 @@ libgstriff_@GST_API_VERSION@_la_LIBADD = \ $(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_API_VERSION@.la \ $(GST_BASE_LIBS) $(GST_LIBS) -libgstriff_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) +libgstriff_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) -DBUILDING_GST_RIFF libgstriff_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) # *** GIR DISABLED for this library *** diff --git a/gst-libs/gst/riff/meson.build b/gst-libs/gst/riff/meson.build index 290d49e..ddda376 100644 --- a/gst-libs/gst/riff/meson.build +++ b/gst-libs/gst/riff/meson.build @@ -16,7 +16,7 @@ install_headers(riff_headers, subdir : 'gstreamer-1.0/gst/riff/') riff_deps = [audio_dep, tag_dep] gstriff = library('gstriff-@0@'.format(api_version), riff_sources, - c_args : gst_plugins_base_args, + c_args : gst_plugins_base_args + ['-DBUILDING_GST_RIFF'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/riff/riff-prelude.h b/gst-libs/gst/riff/riff-prelude.h index fc997a4..fdc932d 100644 --- a/gst-libs/gst/riff/riff-prelude.h +++ b/gst-libs/gst/riff/riff-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_RIFF_API -#define GST_RIFF_API GST_EXPORT +#ifdef BUILDING_GST_RIFF +#define GST_RIFF_API GST_API_EXPORT /* from config.h */ +#else +#define GST_RIFF_API GST_API_IMPORT #endif #endif /* __GST_RIFF_PRELUDE_H__ */ diff --git a/gst-libs/gst/rtp/Makefile.am b/gst-libs/gst/rtp/Makefile.am index f8d11f3..4dce448 100644 --- a/gst-libs/gst/rtp/Makefile.am +++ b/gst-libs/gst/rtp/Makefile.am @@ -25,7 +25,7 @@ libgstrtp_@GST_API_VERSION@_la_SOURCES = gstrtpbuffer.c \ built_sources = gstrtp-enumtypes.c built_headers = gstrtp-enumtypes.h -libgstrtp_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) +libgstrtp_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) -DBUILDING_GST_RTP libgstrtp_@GST_API_VERSION@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) libgstrtp_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) diff --git a/gst-libs/gst/rtp/meson.build b/gst-libs/gst/rtp/meson.build index b466da5..25d3900 100644 --- a/gst-libs/gst/rtp/meson.build +++ b/gst-libs/gst/rtp/meson.build @@ -24,6 +24,7 @@ install_headers(rtp_headers, subdir : 'gstreamer-1.0/gst/rtp/') rtp_enums = gnome.mkenums_simple('gstrtp-enumtypes', sources : rtp_headers, + body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', header_prefix : '#include ', decorator : 'GST_RTP_API', install_header: true, @@ -34,7 +35,7 @@ gstrtp_enum_h = rtp_enums[1] gstrtp_deps = [audio_dep, gst_base_dep] gst_rtp = library('gstrtp-@0@'.format(api_version), rtp_sources, gstrtp_enum_c, gstrtp_enum_h, - c_args : gst_plugins_base_args, + c_args : gst_plugins_base_args + ['-DBUILDING_GST_RTP'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/rtp/rtp-prelude.h b/gst-libs/gst/rtp/rtp-prelude.h index 6f9c537..e130b8a 100644 --- a/gst-libs/gst/rtp/rtp-prelude.h +++ b/gst-libs/gst/rtp/rtp-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_RTP_API -#define GST_RTP_API GST_EXPORT +#ifdef BUILDING_GST_RTP +#define GST_RTP_API GST_API_EXPORT /* from config.h */ +#else +#define GST_RTP_API GST_API_IMPORT #endif #endif /* __GST_RTP_PRELUDE_H__ */ diff --git a/gst-libs/gst/rtsp/Makefile.am b/gst-libs/gst/rtsp/Makefile.am index c933699..02aaf4f 100644 --- a/gst-libs/gst/rtsp/Makefile.am +++ b/gst-libs/gst/rtsp/Makefile.am @@ -34,7 +34,7 @@ nodist_libgstrtspinclude_HEADERS = gstrtsp-enumtypes.h #gstrtspextwms.c #rtspextreal.c -libgstrtsp_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS) +libgstrtsp_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS) -DBUILDING_GST_RTSP libgstrtsp_@GST_API_VERSION@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(GIO_LIBS) $(LIBM) libgstrtsp_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) $(WIN32_LIBS) diff --git a/gst-libs/gst/rtsp/meson.build b/gst-libs/gst/rtsp/meson.build index 86c1e5b..27e309d 100644 --- a/gst-libs/gst/rtsp/meson.build +++ b/gst-libs/gst/rtsp/meson.build @@ -24,6 +24,7 @@ install_headers(rtsp_headers, subdir : 'gstreamer-1.0/gst/rtsp/') rtsp_enums = gnome.mkenums_simple('gstrtsp-enumtypes', sources : rtsp_headers, + body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', header_prefix : '#include ', decorator : 'GST_RTSP_API', install_header: true, @@ -41,7 +42,7 @@ gstrtsp_deps = [gst_base_dep, gst_dep, gio_dep, libm, winsock2] gst_rtsp = library('gstrtsp-@0@'.format(api_version), rtsp_sources, gstrtsp_h, gstrtsp_c, - c_args : gst_plugins_base_args, + c_args : gst_plugins_base_args + ['-DBUILDING_GST_RTSP'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/rtsp/rtsp-prelude.h b/gst-libs/gst/rtsp/rtsp-prelude.h index 34f2113..1086091 100644 --- a/gst-libs/gst/rtsp/rtsp-prelude.h +++ b/gst-libs/gst/rtsp/rtsp-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_RTSP_API -#define GST_RTSP_API GST_EXPORT +#ifdef BUILDING_GST_RTSP +#define GST_RTSP_API GST_API_EXPORT /* from config.h */ +#else +#define GST_RTSP_API GST_API_IMPORT #endif #ifndef GST_DISABLE_DEPRECATED diff --git a/gst-libs/gst/sdp/Makefile.am b/gst-libs/gst/sdp/Makefile.am index f6c4172..cf8c001 100644 --- a/gst-libs/gst/sdp/Makefile.am +++ b/gst-libs/gst/sdp/Makefile.am @@ -10,7 +10,7 @@ lib_LTLIBRARIES = libgstsdp-@GST_API_VERSION@.la libgstsdp_@GST_API_VERSION@_la_SOURCES = gstsdpmessage.c gstmikey.c -libgstsdp_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS) +libgstsdp_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS) -DBUILDING_GST_SDP libgstsdp_@GST_API_VERSION@_la_LIBADD = $(top_builddir)/gst-libs/gst/rtp/libgstrtp-@GST_API_VERSION@.la $(GST_LIBS) $(GIO_LIBS) libgstsdp_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) diff --git a/gst-libs/gst/sdp/meson.build b/gst-libs/gst/sdp/meson.build index 59ffdbc..62c18b7 100644 --- a/gst-libs/gst/sdp/meson.build +++ b/gst-libs/gst/sdp/meson.build @@ -11,7 +11,7 @@ rtsp_deps = [rtp_dep, gst_dep, gio_dep] gst_sdp_sources = ['gstsdpmessage.c', 'gstmikey.c'] gstsdp = library('gstsdp-@0@'.format(api_version), gst_sdp_sources, - c_args : gst_plugins_base_args, + c_args : gst_plugins_base_args + ['-DBUILDING_GST_SDP'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/sdp/sdp-prelude.h b/gst-libs/gst/sdp/sdp-prelude.h index 20f50a4..cecdfd0 100644 --- a/gst-libs/gst/sdp/sdp-prelude.h +++ b/gst-libs/gst/sdp/sdp-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_SDP_API -#define GST_SDP_API GST_EXPORT +#ifdef BUILDING_GST_SDP +#define GST_SDP_API GST_API_EXPORT /* from config.h */ +#else +#define GST_SDP_API GST_API_IMPORT #endif #endif /* __GST_SDP_PRELUDE_H__ */ diff --git a/gst-libs/gst/tag/Makefile.am b/gst-libs/gst/tag/Makefile.am index 5fcc046..83bda29 100644 --- a/gst-libs/gst/tag/Makefile.am +++ b/gst-libs/gst/tag/Makefile.am @@ -30,7 +30,7 @@ libgsttag_@GST_API_VERSION@_la_SOURCES = \ nodist_libgsttag_@GST_API_VERSION@_la_SOURCES = $(BUILT_SOURCES) libgsttag_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(ZLIB_CFLAGS) \ + $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(ZLIB_CFLAGS) -DBUILDING_GST_TAG \ -DLICENSE_TRANSLATIONS_PATH=\"$(pkgdatadir)/@GST_API_VERSION@/license-translations.dict\" libgsttag_@GST_API_VERSION@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) $(ZLIB_LIBS) libgsttag_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) diff --git a/gst-libs/gst/tag/meson.build b/gst-libs/gst/tag/meson.build index 423869c..8ea9d9c 100644 --- a/gst-libs/gst/tag/meson.build +++ b/gst-libs/gst/tag/meson.build @@ -28,6 +28,7 @@ install_headers(tag_headers, subdir : 'gstreamer-1.0/gst/tag/') tag_enums = gnome.mkenums_simple('tag-enumtypes', sources : tag_mkenum_headers, + body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', header_prefix : '#include ', decorator : 'GST_TAG_API', install_header: true, @@ -75,7 +76,7 @@ core_conf.set('HAVE_ZLIB', zlib_dep.found()) tag_deps = [gst_base_dep, libm, zlib_dep] gsttag = library('gsttag-@0@'.format(api_version), tag_sources, gsttag_h, gsttag_c, - c_args : gst_plugins_base_args + gst_tag_args, + c_args : gst_plugins_base_args + gst_tag_args + ['-DBUILDING_GST_TAG'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/tag/tag-prelude.h b/gst-libs/gst/tag/tag-prelude.h index 249683f..96adb0e 100644 --- a/gst-libs/gst/tag/tag-prelude.h +++ b/gst-libs/gst/tag/tag-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_TAG_API -#define GST_TAG_API GST_EXPORT +#ifdef BUILDING_GST_TAG +#define GST_TAG_API GST_API_EXPORT /* from config.h */ +#else +#define GST_TAG_API GST_API_IMPORT #endif #endif /* __GST_TAG_PRELUDE_H__ */ diff --git a/gst-libs/gst/video/Makefile.am b/gst-libs/gst/video/Makefile.am index 5aefe9d..2170a04 100644 --- a/gst-libs/gst/video/Makefile.am +++ b/gst-libs/gst/video/Makefile.am @@ -95,7 +95,7 @@ nodist_libgstvideo_@GST_API_VERSION@include_HEADERS = $(built_headers) noinst_HEADERS = gstvideoutilsprivate.h libgstvideo_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) \ - $(ORC_CFLAGS) + $(ORC_CFLAGS) -DBUILDING_GST_VIDEO libgstvideo_@GST_API_VERSION@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(ORC_LIBS) $(LIBM) libgstvideo_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) diff --git a/gst-libs/gst/video/meson.build b/gst-libs/gst/video/meson.build index 2f9aacb..c0b68d3 100644 --- a/gst-libs/gst/video/meson.build +++ b/gst-libs/gst/video/meson.build @@ -89,6 +89,7 @@ video_mkenum_headers = [ video_enums = gnome.mkenums_simple('video-enumtypes', sources : video_mkenum_headers, + body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', header_prefix : '#include ', decorator : 'GST_VIDEO_API', install_header: true, @@ -120,7 +121,7 @@ endif gstvideo = library('gstvideo-@0@'.format(api_version), video_sources, gstvideo_h, gstvideo_c, orc_c, orc_h, - c_args : gst_plugins_base_args, + c_args : gst_plugins_base_args + ['-DBUILDING_GST_VIDEO'], include_directories: [configinc, libsinc], version : libversion, soversion : soversion, diff --git a/gst-libs/gst/video/video-prelude.h b/gst-libs/gst/video/video-prelude.h index bde26bf..c9f249e 100644 --- a/gst-libs/gst/video/video-prelude.h +++ b/gst-libs/gst/video/video-prelude.h @@ -24,8 +24,10 @@ #include -#ifndef GST_VIDEO_API -#define GST_VIDEO_API GST_EXPORT +#ifdef BUILDING_GST_VIDEO +#define GST_VIDEO_API GST_API_EXPORT /* from config.h */ +#else +#define GST_VIDEO_API GST_API_IMPORT #endif #endif /* __GST_VIDEO_PRELUDE_H__ */ diff --git a/meson.build b/meson.build index 6f940b8..d1c31a6 100644 --- a/meson.build +++ b/meson.build @@ -59,11 +59,21 @@ if cc.has_link_argument('-Wl,-Bsymbolic-functions') add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c') endif +core_conf = configuration_data() + # Symbol visibility -if cc.has_argument('-fvisibility=hidden') +if cc.get_id() == 'msvc' + export_define = '__declspec(dllexport) extern' +elif cc.has_argument('-fvisibility=hidden') add_project_arguments('-fvisibility=hidden', language: 'c') + export_define = 'extern __attribute__ ((visibility ("default")))' +else + export_define = 'extern' endif +# Passing this through the command line would be too messy +core_conf.set('GST_API_EXPORT', export_define) + # Disable strict aliasing if cc.has_argument('-fno-strict-aliasing') add_project_arguments('-fno-strict-aliasing', language: 'c') @@ -93,7 +103,6 @@ if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev) add_project_arguments('-DG_DISABLE_CHECKS', language: 'c') endif -core_conf = configuration_data() check_headers = [ ['HAVE_DLFCN_H', 'dlfcn.h'], ['HAVE_EMMINTRIN_H', 'emmintrin.h'],