mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 11:15:31 +00:00
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
This commit is contained in:
parent
50038bed79
commit
46ed0f0489
16 changed files with 31 additions and 11 deletions
|
@ -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 \
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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')],
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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__ */
|
||||
|
|
Loading…
Reference in a new issue