gstconfig: Use __declspec when built with MinGW and linking with MSVC

Earlier we were only using __declspec(dllexport/import) when we were
built with MSVC because when built with MinGW and linking with MinGW we
don't need it (and we get linker errors because of it).

However, when we're built with MinGW and someone wants to link to us
with MSVC, we still need the prototypes to have __declspec(dllimport)
since MSVC cannot do auto-import like GCC can.

https://bugzilla.gnome.org/show_bug.cgi?id=771029
This commit is contained in:
Nirbheek Chauhan 2016-09-08 12:58:54 +05:30
parent c7e0299d24
commit b6e69ffdfb
3 changed files with 16 additions and 13 deletions

View file

@ -133,8 +133,8 @@ AG_GST_SET_PACKAGE_RELEASE_DATETIME_WITH_NANO([$PACKAGE_VERSION_NANO],
# We only use this when building with MSVC, which is only done with the
# alternate Meson build system files
GSTCONFIG_USE_MSVC_DECLSPEC=0
AC_SUBST(GSTCONFIG_USE_MSVC_DECLSPEC)
GSTCONFIG_BUILT_WITH_MSVC=0
AC_SUBST(GSTCONFIG_BUILT_WITH_MSVC)
dnl check for bash completion
AC_ARG_WITH([bash-completion-dir],

View file

@ -128,14 +128,17 @@
* On Windows, this exports the plugin definition from the DLL.
* On other platforms, this gets defined as a no-op.
*/
/* Only use __declspec(dllexport/import) when we have been built with MSVC.
* With MinGW we still rely on the linker to auto-export/import symbols.
/* Only use __declspec(dllexport/import) when we have been built with MSVC or
* the user is linking to us with MSVC. The only remaining case is when we were
* built with MinGW and are linking with MinGW in which case we rely on the
* linker to auto-export/import symbols. Of course all this is only used when
* not linking statically.
*
* NOTE: To link to GStreamer statically on Windows, you must define
* GST_STATIC_COMPILATION or the prototypes will cause the compiler to search
* for the symbol inside a DLL.
*/
#if @GSTCONFIG_USE_MSVC_DECLSPEC@ && !defined(GST_STATIC_COMPILATION)
#if (@GSTCONFIG_BUILT_WITH_MSVC@ || defined(_MSC_VER)) && !defined(GST_STATIC_COMPILATION)
# define GST_PLUGIN_EXPORT __declspec(dllexport)
# ifdef GST_EXPORTS
# define GST_EXPORT __declspec(dllexport)

View file

@ -187,6 +187,14 @@ if cc.has_type('ptrdiff_t')
cdata.set('HAVE_PTRDIFF_T')
endif
# We only want to use the __declspec(dllexport/import) dance in GST_EXPORT when
# building with MSVC
if cc.get_id() == 'msvc'
cdata.set('GSTCONFIG_BUILT_WITH_MSVC', 1)
else
cdata.set('GSTCONFIG_BUILT_WITH_MSVC', 0)
endif
# -------------------------------------------------------------------------------------
# config.h things needed by libcheck (FIXME: move into the libcheck meson.build) (tpm)
# -------------------------------------------------------------------------------------
@ -221,14 +229,6 @@ if cc.has_function('strsignal', prefix : '#include <string.h>')
cdata.set('HAVE_DECL_STRSIGNAL', 1)
endif
# We only want to use the __declspec(dllexport/import) dance in GST_EXPORT when
# building with MSVC
if cc.get_id() == 'msvc'
cdata.set('GSTCONFIG_USE_MSVC_DECLSPEC', 1)
else
cdata.set('GSTCONFIG_USE_MSVC_DECLSPEC', 0)
endif
configure_file(input : 'config.h.meson',
output : 'config.h',
configuration : cdata)