Ozkan Sezer
2014-May-24 06:16 UTC
[flac-dev] make dllimport/dllexport attributes work with mingw (and others)
The following patch changes export.h so that the dllimport/dllexport attributes work with mingw/mingw-w64 and others: - changes _declspec keyword to __declspec: the former may not be defined by some toolchains. - changes the _MSC_VER condition to universally _WIN32: MSVC, as well as GCC supports this. Attached patch: declspec.diff Regards. -- O.S. -------------- next part -------------- diff --git a/include/FLAC/export.h b/include/FLAC/export.h index 2232b41..4b2418f 100644 --- a/include/FLAC/export.h +++ b/include/FLAC/export.h @@ -59,11 +59,11 @@ #if defined(FLAC__NO_DLL) #define FLAC_API -#elif defined(_MSC_VER) +#elif defined(_WIN32) /*defined(_MSC_VER)*/ #ifdef FLAC_API_EXPORTS -#define FLAC_API _declspec(dllexport) +#define FLAC_API __declspec(dllexport) #else -#define FLAC_API _declspec(dllimport) +#define FLAC_API __declspec(dllimport) #endif #elif defined(FLAC__USE_VISIBILITY_ATTR) diff --git a/include/FLAC++/export.h b/include/FLAC++/export.h index 11c09e6..ab9b439 100644 --- a/include/FLAC++/export.h +++ b/include/FLAC++/export.h @@ -59,11 +59,11 @@ #if defined(FLAC__NO_DLL) #define FLACPP_API -#elif defined(_MSC_VER) +#elif defined(_WIN32) /*defined(_MSC_VER)*/ #ifdef FLACPP_API_EXPORTS -#define FLACPP_API _declspec(dllexport) +#define FLACPP_API __declspec(dllexport) #else -#define FLACPP_API _declspec(dllimport) +#define FLACPP_API __declspec(dllimport) #endif #elif defined(FLAC__USE_VISIBILITY_ATTR)
lvqcl
2014-May-24 07:12 UTC
[flac-dev] make dllimport/dllexport attributes work with mingw (and others)
Ozkan Sezer <sezeroz at gmail.com> ?????(?) ? ????? ?????? Sat, 24 May 2014 10:16:15 +0400:> - changes the _MSC_VER condition to universally _WIN32: MSVC, as well > as GCC supports this.MSYS/MinGW 4.8.3, 4.9.0 can't compile code from git after this patch: format.c:47:22: error: variable 'FLAC__VERSION_STRING' definition is marked dllimport FLAC_API const char *FLAC__VERSION_STRING = VERSION; ^ format.c:47:22: warning: 'FLAC__VERSION_STRING' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] format.c:49:22: error: variable 'FLAC__VENDOR_STRING' definition is marked dllimport FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION " 20130526"; ^ format.c:49:22: warning: 'FLAC__VENDOR_STRING' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] ... ... FLAC_API_EXPORTS macro is defined in libFLAC_dynamic.vcproj, FLACPP_API_EXPORTS macro is defined in libFLAC++_dynamic.vcproj, but MinGW/GCC makefiles don't define them anywhere.
Ozkan Sezer
2014-May-24 21:28 UTC
[flac-dev] make dllimport/dllexport attributes work with mingw (and others)
On 5/24/14, lvqcl <lvqcl.mail at gmail.com> wrote:> Ozkan Sezer <sezeroz at gmail.com> ?????(?) ? ????? ?????? Sat, 24 May 2014 > 10:16:15 +0400: > >> - changes the _MSC_VER condition to universally _WIN32: MSVC, as well >> as GCC supports this. > > MSYS/MinGW 4.8.3, 4.9.0 can't compile code from git after this patch: > > format.c:47:22: error: variable 'FLAC__VERSION_STRING' definition is marked > dllimport > FLAC_API const char *FLAC__VERSION_STRING = VERSION; > ^ > format.c:47:22: warning: 'FLAC__VERSION_STRING' redeclared without dllimport > attribute: previous dllimport ignored [-Wattributes] > format.c:49:22: error: variable 'FLAC__VENDOR_STRING' definition is marked > dllimport > FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION " > 20130526"; > ^ > format.c:49:22: warning: 'FLAC__VENDOR_STRING' redeclared without dllimport > attribute: previous dllimport ignored [-Wattributes] > > ... > ... > > > FLAC_API_EXPORTS macro is defined in libFLAC_dynamic.vcproj, > FLACPP_API_EXPORTS macro is defined in libFLAC++_dynamic.vcproj, > but MinGW/GCC makefiles don't define them anywhere.My apologies, obviously sent an old testing patch. Correct one is attached (declspec2.diff). Compilation tested using MinGW (gcc-3.4.5, binutils-2.20), and MinGW-w64 (gcc-4.5.4, binutils-2.21.90.) -- O.S. -------------- next part -------------- diff --git a/include/FLAC/export.h b/include/FLAC/export.h index 2232b41..185c282 100644 --- a/include/FLAC/export.h +++ b/include/FLAC/export.h @@ -59,11 +59,11 @@ #if defined(FLAC__NO_DLL) #define FLAC_API -#elif defined(_MSC_VER) -#ifdef FLAC_API_EXPORTS -#define FLAC_API _declspec(dllexport) +#elif defined(_WIN32) +#if defined(FLAC_API_EXPORTS) || defined(DLL_EXPORT) +#define FLAC_API __declspec(dllexport) #else -#define FLAC_API _declspec(dllimport) +#define FLAC_API __declspec(dllimport) #endif #elif defined(FLAC__USE_VISIBILITY_ATTR) diff --git a/include/FLAC++/export.h b/include/FLAC++/export.h index 11c09e6..91649a5 100644 --- a/include/FLAC++/export.h +++ b/include/FLAC++/export.h @@ -59,11 +59,11 @@ #if defined(FLAC__NO_DLL) #define FLACPP_API -#elif defined(_MSC_VER) -#ifdef FLACPP_API_EXPORTS -#define FLACPP_API _declspec(dllexport) +#elif defined(_WIN32) +#if defined(FLACPP_API_EXPORTS) || defined(DLL_EXPORT) +#define FLACPP_API __declspec(dllexport) #else -#define FLACPP_API _declspec(dllimport) +#define FLACPP_API __declspec(dllimport) #endif #elif defined(FLAC__USE_VISIBILITY_ATTR) diff --git a/src/flac/Makefile.am b/src/flac/Makefile.am index 389215e..a4929ab 100644 --- a/src/flac/Makefile.am +++ b/src/flac/Makefile.am @@ -44,6 +44,9 @@ flac_SOURCES = \ utils.h \ vorbiscomment.h +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +endif flac_LDADD = \ $(top_builddir)/src/share/utf8/libutf8.la \ $(top_builddir)/src/share/grabbag/libgrabbag.la \ @@ -51,7 +54,7 @@ flac_LDADD = \ $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ $(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \ $(top_builddir)/src/libFLAC/libFLAC.la \ - @LIBICONV@ \ + $(win_utf8_lib) @LIBICONV@ \ -lm CLEANFILES = flac.exe diff --git a/src/metaflac/Makefile.am b/src/metaflac/Makefile.am index d6e76e8..94fda50 100644 --- a/src/metaflac/Makefile.am +++ b/src/metaflac/Makefile.am @@ -42,12 +42,15 @@ metaflac_SOURCES = \ utils.h metaflac_LDFLAGS = $(AM_LDFLAGS) +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +endif metaflac_LDADD = \ $(top_builddir)/src/share/grabbag/libgrabbag.la \ $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ $(top_builddir)/src/share/getopt/libgetopt.la \ $(top_builddir)/src/share/utf8/libutf8.la \ $(top_builddir)/src/libFLAC/libFLAC.la \ - @LIBICONV@ + $(win_utf8_lib) @LIBICONV@ CLEANFILES = metaflac.exe diff --git a/src/test_grabbag/cuesheet/Makefile.am b/src/test_grabbag/cuesheet/Makefile.am index a7fc5c5..134afb2 100644 --- a/src/test_grabbag/cuesheet/Makefile.am +++ b/src/test_grabbag/cuesheet/Makefile.am @@ -24,8 +24,13 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include noinst_PROGRAMS = test_cuesheet test_cuesheet_SOURCES = \ main.c + +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +endif test_cuesheet_LDADD = \ $(top_builddir)/src/share/grabbag/libgrabbag.la \ + $(win_utf8_lib) \ $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ $(top_builddir)/src/libFLAC/libFLAC.la diff --git a/src/test_grabbag/picture/Makefile.am b/src/test_grabbag/picture/Makefile.am index 677fe5c..83af1e8 100644 --- a/src/test_grabbag/picture/Makefile.am +++ b/src/test_grabbag/picture/Makefile.am @@ -25,8 +25,12 @@ noinst_PROGRAMS = test_picture test_picture_SOURCES = \ main.c +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +endif test_picture_LDADD = \ $(top_builddir)/src/share/grabbag/libgrabbag.la \ + $(win_utf8_lib) \ $(top_builddir)/src/libFLAC/libFLAC.la CLEANFILES = test_picture.exe diff --git a/src/test_libFLAC++/Makefile.am b/src/test_libFLAC++/Makefile.am index 281557d..98eee9e 100644 --- a/src/test_libFLAC++/Makefile.am +++ b/src/test_libFLAC++/Makefile.am @@ -22,13 +22,17 @@ EXTRA_DIST = \ AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include noinst_PROGRAMS = test_libFLAC++ + +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +endif test_libFLAC___LDADD = \ $(top_builddir)/src/share/grabbag/libgrabbag.la \ $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ $(top_builddir)/src/test_libs_common/libtest_libs_common.la \ $(top_builddir)/src/libFLAC++/libFLAC++.la \ $(top_builddir)/src/libFLAC/libFLAC.la \ - @OGG_LIBS@ \ + $(win_utf8_lib) @OGG_LIBS@ \ -lm test_libFLAC___SOURCES = \ diff --git a/src/test_libFLAC/Makefile.am b/src/test_libFLAC/Makefile.am index 407c8ea..5c3d4f1 100644 --- a/src/test_libFLAC/Makefile.am +++ b/src/test_libFLAC/Makefile.am @@ -25,6 +25,7 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$( noinst_PROGRAMS = test_libFLAC if OS_IS_WINDOWS +AM_CPPFLAGS += -DFLAC__NO_DLL win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la endif diff --git a/src/test_seeking/Makefile.am b/src/test_seeking/Makefile.am index 87ddb36..bb7a564 100644 --- a/src/test_seeking/Makefile.am +++ b/src/test_seeking/Makefile.am @@ -25,8 +25,13 @@ AM_CFLAGS = @OGG_CFLAGS@ AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include noinst_PROGRAMS = test_seeking + +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +endif + test_seeking_LDADD = \ - $(top_builddir)/src/libFLAC/libFLAC.la + $(win_utf8_lib) $(top_builddir)/src/libFLAC/libFLAC.la test_seeking_SOURCES = \ main.c
Maybe Matching Threads
- make dllimport/dllexport attributes work with mingw (and others)
- Building FLAC with LTO
- make dllimport/dllexport attributes work with mingw (and others)
- make dllimport/dllexport attributes work with mingw (and others)
- [PATCH 1/5] Remove old GNU-stack sections from nasm files.