[vlc-devel] [PATCH] Fix libmod_plugin undefined __imp_ symbols building for win32
Konstantinos Tsanaktsidis
kjtsanaktsidis at gmail.com
Thu Jun 12 12:34:50 CEST 2014
When building current HEAD of master for x86_64-w64-mingw32 against current
contribs, compilation fails at libmod_plugin due to undefined symbols of
the form __imp_ModPlug_*. This patch modifies the demux Makefile to define
the preprocessor macro MODPLUG_STATIC, which fixes the build.
This problem occurs because of the following code in
contrib/x86_64-w64-mingw32/include/libmodplug/modplug.h. This code is
present in libmodplug obtained from running "make fetch & make" in the
contribs directory, but not present in the prebuilt contribs obtained from
running "make prebuilt".
#if defined(_WIN32) || defined(__CYGWIN__)
# if defined(MODPLUG_BUILD) && defined(DLL_EXPORT)
# define MODPLUG_EXPORT __declspec(dllexport)
# elif defined(MODPLUG_BUILD) || defined(MODPLUG_STATIC)
# define MODPLUG_EXPORT
# else
# define MODPLUG_EXPORT __declspec(dllimport)
# endif
When building for Windows, if MODPLUG_STATIC is not defined, MODPLUG_EXPORT
is defined as "__declspec(dllimport)". On Windows, dynamic symbols are
prefixed with "__imp_", so this causes GCC to adjust the symbol references
to the libmodplug functions accordingly.
This patch therefore sets libmod_plugin_la_CPPFLAGS to define the
MODPLUG_STATIC macro, which causes modplug.h to not define MODPLUG_EXPORT
in this way. An alternative option would be to add a patch to contribs
to remove this behaviour from modplug.h, but this seems cleaner.
---
modules/demux/Makefile.am | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index c19caf1..cb04b3a 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -42,6 +42,11 @@ demux_LTLIBRARIES += libps_plugin.la
libmod_plugin_la_SOURCES = demux/mod.c
libmod_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(CXXFLAGS_mod)
+#We need to build with MODPLUG_STATIC defined
+#on non-windows this has no effect
+#on windows, it makes sure that libmodplug prototypes are not defined
+#with __declspec(dllimport)
+libmod_plugin_la_CPPFLAGS = -DMODPLUG_STATIC
libmod_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(demuxdir)'
libmod_plugin_la_LIBADD = $(LIBS_mod)
EXTRA_LTLIBRARIES += libmod_plugin.la
--
1.9.1
More information about the vlc-devel
mailing list