libs: fix API export/import and 'inconsistent linkage' on MSVC

Export rtsp-server library API in headers when we're building the
library itself, otherwise import the API from the headers.

This fixes linker warnings on Windows when building with MSVC.

Fix up some missing config.h includes when building the lib which
is needed to get the export api define from config.h

https://bugzilla.gnome.org/show_bug.cgi?id=797185
This commit is contained in:
Tim-Philipp Müller 2018-09-24 09:36:21 +01:00
parent ff51e9a68d
commit 62d4c0b179
24 changed files with 84 additions and 6 deletions

View file

@ -258,7 +258,13 @@ fi
AC_SUBST(DEPRECATED_CFLAGS) AC_SUBST(DEPRECATED_CFLAGS)
VISIBILITY_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) AC_SUBST(VISIBILITY_CFLAGS)
dnl disable strict aliasing dnl disable strict aliasing

View file

@ -59,7 +59,7 @@ libgstrtspserver_@GST_API_VERSION@_la_SOURCES = \
libgstrtspserver_@GST_API_VERSION@_la_CFLAGS = \ libgstrtspserver_@GST_API_VERSION@_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) $(GST_NET_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) $(GST_NET_CFLAGS) \
$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) -DBUILDING_GST_RTSP_SERVER
libgstrtspserver_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) libgstrtspserver_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
libgstrtspserver_@GST_API_VERSION@_la_LIBADD = \ libgstrtspserver_@GST_API_VERSION@_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) $(GST_NET_LIBS) $(GST_BASE_LIBS) \ $(GST_PLUGINS_BASE_LIBS) $(GST_NET_LIBS) $(GST_BASE_LIBS) \

View file

@ -48,7 +48,7 @@ gst_rtsp_server_deps = [gstrtsp_dep, gstrtp_dep, gstsdp_dep, gstnet_dep, gstapp_
gst_rtsp_server = library('gstrtspserver-@0@'.format(api_version), gst_rtsp_server = library('gstrtspserver-@0@'.format(api_version),
rtsp_server_sources, rtsp_server_sources,
include_directories : rtspserver_incs, include_directories : rtspserver_incs,
c_args: rtspserver_args, c_args: rtspserver_args + ['-DBUILDING_GST_RTSP_SERVER'],
version : libversion, version : libversion,
soversion : soversion, soversion : soversion,
darwin_versions : osxversion, darwin_versions : osxversion,

View file

@ -36,6 +36,9 @@
* *
* Last reviewed on 2013-07-16 (1.0.0) * Last reviewed on 2013-07-16 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>
#include <gio/gio.h> #include <gio/gio.h>

View file

@ -45,6 +45,9 @@
* *
* Last reviewed on 2013-07-16 (1.0.0) * Last reviewed on 2013-07-16 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>

View file

@ -40,6 +40,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View file

@ -23,6 +23,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtsp-context.h" #include "rtsp-context.h"

View file

@ -29,6 +29,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>

View file

@ -37,6 +37,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtsp-media-factory.h" #include "rtsp-media-factory.h"

View file

@ -62,6 +62,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View file

@ -34,6 +34,10 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>
#include "rtsp-mount-points.h" #include "rtsp-mount-points.h"

View file

@ -23,6 +23,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>

View file

@ -36,6 +36,9 @@
* *
* Last reviewed on 2013-07-15 (1.0.0) * Last reviewed on 2013-07-15 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>

View file

@ -26,6 +26,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>

View file

@ -25,7 +25,11 @@
#include <gst/gst.h> #include <gst/gst.h>
#ifndef GST_RTSP_SERVER_API #ifndef GST_RTSP_SERVER_API
#define GST_RTSP_SERVER_API GST_EXPORT # ifdef BUILDING_GST_RTSP_SERVER
# define GST_RTSP_SERVER_API GST_API_EXPORT /* from config.h */
# else
# define GST_RTSP_SERVER_API GST_API_IMPORT
# endif
#endif #endif
#endif /* __GST_RTSP_SERVER_PRELUDE_H__ */ #endif /* __GST_RTSP_SERVER_PRELUDE_H__ */

View file

@ -52,6 +52,10 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View file

@ -34,6 +34,9 @@
* *
* Last reviewed on 2013-07-16 (1.0.0) * Last reviewed on 2013-07-16 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>

View file

@ -39,6 +39,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rtsp-session-pool.h" #include "rtsp-session-pool.h"

View file

@ -42,6 +42,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>

View file

@ -40,6 +40,9 @@
* *
* Last reviewed on 2013-07-16 (1.0.0) * Last reviewed on 2013-07-16 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -45,6 +45,9 @@
* *
* Last reviewed on 2013-07-16 (1.0.0) * Last reviewed on 2013-07-16 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View file

@ -46,6 +46,9 @@
* *
* Last reviewed on 2013-07-11 (1.0.0) * Last reviewed on 2013-07-11 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>

View file

@ -35,6 +35,9 @@
* *
* Last reviewed on 2013-07-15 (1.0.0) * Last reviewed on 2013-07-15 (1.0.0)
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> #include <string.h>

View file

@ -30,15 +30,25 @@ plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
cdata = configuration_data()
if cc.has_link_argument('-Wl,-Bsymbolic-functions') if cc.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c') add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
endif endif
# Symbol visibility # 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') add_project_arguments('-fvisibility=hidden', language: 'c')
export_define = 'extern __attribute__ ((visibility ("default")))'
else
export_define = 'extern'
endif endif
# Passing this through the command line would be too messy
cdata.set('GST_API_EXPORT', export_define)
# Disable strict aliasing # Disable strict aliasing
if cc.has_argument('-fno-strict-aliasing') if cc.has_argument('-fno-strict-aliasing')
add_project_arguments('-fno-strict-aliasing', language: 'c') add_project_arguments('-fno-strict-aliasing', language: 'c')
@ -68,7 +78,6 @@ if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
add_project_arguments('-DG_DISABLE_CHECKS', language: 'c') add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
endif endif
cdata = configuration_data()
cdata.set_quoted('GETTEXT_PACKAGE', 'gst-rtsp-server-1.0') cdata.set_quoted('GETTEXT_PACKAGE', 'gst-rtsp-server-1.0')
cdata.set_quoted('PACKAGE', 'gst-rtsp-server') cdata.set_quoted('PACKAGE', 'gst-rtsp-server')
cdata.set_quoted('VERSION', gst_version) cdata.set_quoted('VERSION', gst_version)