summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2018-08-25 23:09:12 +0200
committerTim-Philipp Müller <tim@centricular.com>2018-09-23 23:23:01 +0100
commit46ed0f0489896824f45694b5d8fbdfaac8de6504 (patch)
tree88e076418b3bd1f9c4790000ed25062c6cf3fc3c
parent50038bed79e056eee109572db03113999cc7eb38 (diff)
downloadgstreamer-46ed0f0489896824f45694b5d8fbdfaac8de6504.tar.gz
libs: fix 'inconsistent DLL linkage' warnings on Windows
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. https://bugzilla.gnome.org/show_bug.cgi?id=797185
-rw-r--r--gst/Makefile.am2
-rw-r--r--gst/gstconfig.h.in4
-rw-r--r--gst/meson.build3
-rw-r--r--gst/parse/Makefile.am2
-rw-r--r--libs/gst/base/Makefile.am2
-rw-r--r--libs/gst/base/base-prelude.h4
-rw-r--r--libs/gst/base/meson.build2
-rw-r--r--libs/gst/check/Makefile.am1
-rw-r--r--libs/gst/check/check-prelude.h4
-rw-r--r--libs/gst/check/meson.build2
-rw-r--r--libs/gst/controller/Makefile.am2
-rw-r--r--libs/gst/controller/controller-prelude.h4
-rw-r--r--libs/gst/controller/meson.build2
-rw-r--r--libs/gst/net/Makefile.am2
-rw-r--r--libs/gst/net/meson.build2
-rw-r--r--libs/gst/net/net-prelude.h4
16 files changed, 31 insertions, 11 deletions
diff --git a/gst/Makefile.am b/gst/Makefile.am
index 78d10c23e4..1ca0765a47 100644
--- a/gst/Makefile.am
+++ b/gst/Makefile.am
@@ -136,7 +136,7 @@ DISTCLEANFILES = $(built_headers_configure)
libgstreamer_@GST_API_VERSION@_la_CFLAGS = \
-D_GNU_SOURCE \
- -DGST_EXPORTS \
+ -DBUILDING_GST \
-DG_LOG_DOMAIN=g_log_domain_gstreamer \
-DGST_API_VERSION=\""$(GST_API_VERSION)"\" \
-DGST_DISABLE_DEPRECATED \
diff --git a/gst/gstconfig.h.in b/gst/gstconfig.h.in
index cb92a2c5e8..a0f57710cd 100644
--- a/gst/gstconfig.h.in
+++ b/gst/gstconfig.h.in
@@ -162,7 +162,11 @@
#endif
#ifndef GST_API
+# ifdef BUILDING_GST
#define GST_API GST_EXPORT
+# else
+# define GST_API GST_API_IMPORT
+# endif
#endif
/* These macros are used to mark deprecated functions in GStreamer headers,
diff --git a/gst/meson.build b/gst/meson.build
index d6eb4a2a70..4ad217056d 100644
--- a/gst/meson.build
+++ b/gst/meson.build
@@ -219,7 +219,6 @@ subdir('printf')
libgst_c_args = gst_c_args + [
'-D_GNU_SOURCE',
- '-DGST_EXPORTS',
'-DG_LOG_DOMAIN=g_log_domain_gstreamer',
'-DGST_DISABLE_DEPRECATED',
]
@@ -237,7 +236,7 @@ libgst = library('gstreamer-1.0', gst_sources,
version : libversion,
soversion : soversion,
darwin_versions : osxversion,
- c_args : libgst_c_args,
+ c_args : libgst_c_args + ['-DBUILDING_GST'],
include_directories : [configinc,
# HACK, change include paths in .y and .l in final version.
include_directories('parse')],
diff --git a/gst/parse/Makefile.am b/gst/parse/Makefile.am
index 844349a104..daf89ce70a 100644
--- a/gst/parse/Makefile.am
+++ b/gst/parse/Makefile.am
@@ -14,7 +14,7 @@ EXTRA_DIST = \
nodist_libgstparse_la_SOURCES = lex.priv_gst_parse_yy.c grammar.tab.c grammar.tag.h parse_lex.h
CLEANFILES += grammar.tab.c lex.priv_gst_parse_yy.c
-libgstparse_la_CFLAGS = $(GST_ALL_CFLAGS) -DGST_EXPORTS -DYYMALLOC=g_malloc -DYYFREE=g_free
+libgstparse_la_CFLAGS = $(GST_ALL_CFLAGS) -DBUILDING_GST -DYYMALLOC=g_malloc -DYYFREE=g_free
libgstparse_la_LIBADD = $(GST_ALL_LIBS)
noinst_HEADERS = types.h
diff --git a/libs/gst/base/Makefile.am b/libs/gst/base/Makefile.am
index 199a25a2b3..8439ebf144 100644
--- a/libs/gst/base/Makefile.am
+++ b/libs/gst/base/Makefile.am
@@ -20,7 +20,7 @@ libgstbase_@GST_API_VERSION@_la_SOURCES = \
gstqueuearray.c \
gsttypefindhelper.c
-libgstbase_@GST_API_VERSION@_la_CFLAGS = $(GST_OBJ_CFLAGS)
+libgstbase_@GST_API_VERSION@_la_CFLAGS = $(GST_OBJ_CFLAGS) -DBUILDING_GST_BASE
libgstbase_@GST_API_VERSION@_la_LIBADD = $(GST_OBJ_LIBS)
libgstbase_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
diff --git a/libs/gst/base/base-prelude.h b/libs/gst/base/base-prelude.h
index 4392817d2b..ae98d38d19 100644
--- a/libs/gst/base/base-prelude.h
+++ b/libs/gst/base/base-prelude.h
@@ -25,7 +25,11 @@
#include <gst/gst.h>
#ifndef GST_BASE_API
+#ifdef BUILDING_GST_BASE
#define GST_BASE_API GST_EXPORT
+#else
+#define GST_BASE_API GST_API_IMPORT
+#endif
#endif
#endif /* __GST_BASE_PRELUDE_H__ */
diff --git a/libs/gst/base/meson.build b/libs/gst/base/meson.build
index 7c38a09cbb..4d0c4e9493 100644
--- a/libs/gst/base/meson.build
+++ b/libs/gst/base/meson.build
@@ -42,7 +42,7 @@ gst_base_gen_sources = []
gst_base = library('gstbase-@0@'.format(apiversion),
gst_base_sources,
- c_args : gst_c_args,
+ c_args : gst_c_args + ['-DBUILDING_GST_BASE'],
version : libversion,
soversion : soversion,
darwin_versions : osxversion,
diff --git a/libs/gst/check/Makefile.am b/libs/gst/check/Makefile.am
index 61a03bcad4..f84cecd1aa 100644
--- a/libs/gst/check/Makefile.am
+++ b/libs/gst/check/Makefile.am
@@ -14,6 +14,7 @@ libgstcheck_@GST_API_VERSION@_la_SOURCES = \
libgstcheck_@GST_API_VERSION@_la_CFLAGS = $(GST_OBJ_CFLAGS) \
-UG_DISABLE_ASSERT \
+ -DBUILDING_GST_CHECK \
-I$(top_builddir)/libs \
-I$(top_builddir)/libs/gst/check \
-I$(top_builddir)/libs/gst/check/libcheck
diff --git a/libs/gst/check/check-prelude.h b/libs/gst/check/check-prelude.h
index bb05c11d0d..f7faf83fd7 100644
--- a/libs/gst/check/check-prelude.h
+++ b/libs/gst/check/check-prelude.h
@@ -25,7 +25,11 @@
#include <gst/gst.h>
#ifndef GST_CHECK_API
+#ifdef BUILDING_GST_CHECK
#define GST_CHECK_API GST_EXPORT
+#else
+#define GST_CHECK_API GST_API_IMPORT
+#endif
#endif
#ifndef GST_DISABLE_DEPRECATED
diff --git a/libs/gst/check/meson.build b/libs/gst/check/meson.build
index 2068718f4b..9cbc11d67e 100644
--- a/libs/gst/check/meson.build
+++ b/libs/gst/check/meson.build
@@ -39,7 +39,7 @@ configure_file(input : 'libcheck/check.h.in',
gst_check = shared_library('gstcheck-@0@'.format(apiversion),
gst_check_sources,
- c_args : gst_c_args + ['-DGST_EXPORTS', '-UG_DISABLE_ASSERT'],
+ c_args : gst_c_args + ['-UG_DISABLE_ASSERT', '-DBUILDING_GST_CHECK'],
version : libversion,
soversion : soversion,
darwin_versions : osxversion,
diff --git a/libs/gst/controller/Makefile.am b/libs/gst/controller/Makefile.am
index b1675c78e7..f5bdcac41a 100644
--- a/libs/gst/controller/Makefile.am
+++ b/libs/gst/controller/Makefile.am
@@ -40,7 +40,7 @@ libgstcontroller_@GST_API_VERSION@_la_SOURCES = \
nodist_libgstcontroller_@GST_API_VERSION@_la_SOURCES = $(BUILT_SOURCES)
-libgstcontroller_@GST_API_VERSION@_la_CFLAGS = $(GST_OBJ_CFLAGS)
+libgstcontroller_@GST_API_VERSION@_la_CFLAGS = $(GST_OBJ_CFLAGS) -DBUILDING_GST_CONTROLLER
libgstcontroller_@GST_API_VERSION@_la_LIBADD = $(GST_OBJ_LIBS) $(LIBM)
libgstcontroller_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
diff --git a/libs/gst/controller/controller-prelude.h b/libs/gst/controller/controller-prelude.h
index 852b53dcde..c7d278cdc8 100644
--- a/libs/gst/controller/controller-prelude.h
+++ b/libs/gst/controller/controller-prelude.h
@@ -25,7 +25,11 @@
#include <gst/gst.h>
#ifndef GST_CONTROLLER_API
+#ifdef BUILDING_GST_CONTROLLER
#define GST_CONTROLLER_API GST_EXPORT
+#else
+#define GST_CONTROLLER_API GST_API_IMPORT
+#endif
#endif
#endif /* __GST_CONTROLLER_PRELUDE_H__ */
diff --git a/libs/gst/controller/meson.build b/libs/gst/controller/meson.build
index e58dbedaf0..93a5beccc4 100644
--- a/libs/gst/controller/meson.build
+++ b/libs/gst/controller/meson.build
@@ -38,7 +38,7 @@ gstcontroller_h = controller_enums[1]
gst_controller_gen_sources = [gstcontroller_h]
gst_controller = library('gstcontroller-@0@'.format(apiversion),
gst_controller_sources, gstcontroller_h, gstcontroller_c,
- c_args : gst_c_args,
+ c_args : gst_c_args + ['-DBUILDING_GST_CONTROLLER'],
install : true,
version : libversion,
soversion : soversion,
diff --git a/libs/gst/net/Makefile.am b/libs/gst/net/Makefile.am
index de254e9ed6..c0eab7aeb8 100644
--- a/libs/gst/net/Makefile.am
+++ b/libs/gst/net/Makefile.am
@@ -24,7 +24,7 @@ libgstnet_@GST_API_VERSION@_la_SOURCES = \
noinst_HEADERS = gstptp_private.h gstntppacket.h gstnetutils.h
-libgstnet_@GST_API_VERSION@_la_CFLAGS = $(GST_OBJ_CFLAGS) $(GIO_CFLAGS)
+libgstnet_@GST_API_VERSION@_la_CFLAGS = $(GST_OBJ_CFLAGS) $(GIO_CFLAGS) -DBUILDING_GST_NET
libgstnet_@GST_API_VERSION@_la_LIBADD = $(GST_OBJ_LIBS) $(GIO_LIBS) \
$(top_builddir)/libs/gst/base/libgstbase-@GST_API_VERSION@.la
libgstnet_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
diff --git a/libs/gst/net/meson.build b/libs/gst/net/meson.build
index 73bd16e29d..1e631645ed 100644
--- a/libs/gst/net/meson.build
+++ b/libs/gst/net/meson.build
@@ -25,7 +25,7 @@ install_headers(gst_net_headers, subdir : 'gstreamer-1.0/gst/net/')
gst_net_gen_sources = []
gst_net = library('gstnet-@0@'.format(apiversion),
gst_net_sources,
- c_args : gst_c_args,
+ c_args : gst_c_args + ['-DBUILDING_GST_NET'],
include_directories : [configinc, libsinc],
version : libversion,
soversion : soversion,
diff --git a/libs/gst/net/net-prelude.h b/libs/gst/net/net-prelude.h
index 8db756574f..e0cf2f8960 100644
--- a/libs/gst/net/net-prelude.h
+++ b/libs/gst/net/net-prelude.h
@@ -25,7 +25,11 @@
#include <gst/gst.h>
#ifndef GST_NET_API
+#ifdef BUILDING_GST_NET
#define GST_NET_API GST_EXPORT
+#else
+#define GST_NET_API GST_API_IMPORT
+#endif
#endif
#endif /* __GST_NET_PRELUDE_H__ */