aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-10-18 11:53:19 +0300
committerMartin Storsjö <martin@martin.st>2012-10-18 14:26:15 +0300
commitd66c52c2b369401ba4face1c171ccb19130b7a31 (patch)
tree8a960e41649009ed665c5f76d1dd61dabb1440b2 /libavcodec
parenteaa9b2e66c04d234eab85e2991d756ee36858808 (diff)
downloadffmpeg-d66c52c2b369401ba4face1c171ccb19130b7a31.tar.gz
Add support for building shared libraries with MSVC
This requires the makedef perl script by Derek, from the c89-to-c99 repo. That scripts produces a .def file, listing the symbols to be exported, based on the gcc version scripts and the built object files. To properly load non-function symbols from DLL files, the data symbol declarations need to have the attribute __declspec(dllimport) when building the calling code. (On mingw, the linker can fix this up automatically, which is why it has not been an issue so far. If this attribute is omitted, linking actually succeeds, but reads from the table will not produce the desired results at runtime.) MSVC seems to manage to link DLLs (and run properly) even if this attribute is present while building the library itself (which normally isn't recommended) - other object files in the same library manage to link to the symbol (with a small warning at link time, like "warning LNK4049: locally defined symbol _avpriv_mpa_bitrate_tab imported" - it doesn't seem to be possible to squelch this warning), and the definition of the tables themselves produce a warning that can be squelched ("warning C4273: 'avpriv_mpa_bitrate_tab' : inconsistent dll linkage, see previous definition of 'avpriv_mpa_bitrate_tab'). In this setup, mingw isn't able to link object files that refer to data symbols with __declspec(dllimport) without those symbols actually being linked via a DLL (linking avcodec.dll ends up with errors like "undefined reference to `__imp__avpriv_mpa_freq_tab'"). The dllimport declspec isn't needed at all in mingw, so we simply choose not to declare it for other compilers than MSVC that requires it. (If ICL support later requires it, the condition can be extended later to include both of them.) This also implies that code that is built to link to a certain library as a DLL can't link to the same library as a static library. Therefore, we only allow building either static or shared but not both at the same time. (That is, static libraries as such can be, and actually are, built - this is used for linking the test tools to internal symbols in the libraries - but e.g. libavformat built to link to libavcodec as a DLL cannot link statically to libavcodec.) Also, linking to DLLs is slightly different from linking to shared libraries on other platforms. DLLs use a thing called import libraries, which is basically a stub library allowing the linker to know which symbols exist in the DLL and what name the DLL will have at runtime. In mingw/gcc, the import library is usually named libfoo.dll.a, which goes next to a static library named libfoo.a. This allows gcc to pick the dynamic one, if available, from the normal -lfoo switches, just as it does for libfoo.a vs libfoo.so on Unix. On MSVC however, you need to literally specify the name of the import library instead of the static library. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3tab.h2
-rw-r--r--libavcodec/dca.h3
-rw-r--r--libavcodec/mjpeg.h14
-rw-r--r--libavcodec/mpeg4audio.h2
-rw-r--r--libavcodec/mpegaudiodata.h6
5 files changed, 15 insertions, 12 deletions
diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
index 8ed50520e6..c2b3febcb7 100644
--- a/libavcodec/ac3tab.h
+++ b/libavcodec/ac3tab.h
@@ -33,7 +33,7 @@
extern const uint16_t ff_ac3_frame_size_tab[38][3];
extern const uint8_t ff_ac3_channels_tab[8];
-extern const uint16_t avpriv_ac3_channel_layout_tab[8];
+extern av_export const uint16_t avpriv_ac3_channel_layout_tab[8];
extern const uint8_t ff_ac3_enc_channel_map[8][2][6];
extern const uint8_t ff_ac3_dec_channel_map[8][2][6];
extern const uint16_t ff_ac3_sample_rate_tab[3];
diff --git a/libavcodec/dca.h b/libavcodec/dca.h
index 1515270471..76342f0ab9 100644
--- a/libavcodec/dca.h
+++ b/libavcodec/dca.h
@@ -26,6 +26,7 @@
#define AVCODEC_DCA_H
#include <stdint.h>
+#include "libavutil/internal.h"
/** DCA syncwords, also used for bitstream type detection */
#define DCA_MARKER_RAW_BE 0x7FFE8001
@@ -36,6 +37,6 @@
/** DCA-HD specific block starts with this marker. */
#define DCA_HD_MARKER 0x64582025
-extern const uint32_t avpriv_dca_sample_rates[16];
+extern av_export const uint32_t avpriv_dca_sample_rates[16];
#endif /* AVCODEC_DCA_H */
diff --git a/libavcodec/mjpeg.h b/libavcodec/mjpeg.h
index 1374ab319f..a69b519184 100644
--- a/libavcodec/mjpeg.h
+++ b/libavcodec/mjpeg.h
@@ -137,16 +137,16 @@ static inline void put_marker(PutBitContext *p, int code)
case 7: ret= (left + top)>>1; break;\
}
-extern const uint8_t avpriv_mjpeg_bits_dc_luminance[];
-extern const uint8_t avpriv_mjpeg_val_dc[];
+extern av_export const uint8_t avpriv_mjpeg_bits_dc_luminance[];
+extern av_export const uint8_t avpriv_mjpeg_val_dc[];
-extern const uint8_t avpriv_mjpeg_bits_dc_chrominance[];
+extern av_export const uint8_t avpriv_mjpeg_bits_dc_chrominance[];
-extern const uint8_t avpriv_mjpeg_bits_ac_luminance[];
-extern const uint8_t avpriv_mjpeg_val_ac_luminance[];
+extern av_export const uint8_t avpriv_mjpeg_bits_ac_luminance[];
+extern av_export const uint8_t avpriv_mjpeg_val_ac_luminance[];
-extern const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
-extern const uint8_t avpriv_mjpeg_val_ac_chrominance[];
+extern av_export const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
+extern av_export const uint8_t avpriv_mjpeg_val_ac_chrominance[];
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
const uint8_t *bits_table,
diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
index 1ee2d7e2c7..e71122d0d3 100644
--- a/libavcodec/mpeg4audio.h
+++ b/libavcodec/mpeg4audio.h
@@ -40,7 +40,7 @@ typedef struct MPEG4AudioConfig {
int ps; ///< -1 implicit, 1 presence
} MPEG4AudioConfig;
-extern const int avpriv_mpeg4audio_sample_rates[16];
+extern av_export const int avpriv_mpeg4audio_sample_rates[16];
extern const uint8_t ff_mpeg4audio_channels[8];
/**
diff --git a/libavcodec/mpegaudiodata.h b/libavcodec/mpegaudiodata.h
index d1a8841f98..2b8ff6587f 100644
--- a/libavcodec/mpegaudiodata.h
+++ b/libavcodec/mpegaudiodata.h
@@ -29,11 +29,13 @@
#include <stdint.h>
+#include "libavutil/internal.h"
+
#define MODE_EXT_MS_STEREO 2
#define MODE_EXT_I_STEREO 1
-extern const uint16_t avpriv_mpa_bitrate_tab[2][3][15];
-extern const uint16_t avpriv_mpa_freq_tab[3];
+extern av_export const uint16_t avpriv_mpa_bitrate_tab[2][3][15];
+extern av_export const uint16_t avpriv_mpa_freq_tab[3];
extern const int ff_mpa_sblimit_table[5];
extern const int ff_mpa_quant_steps[17];
extern const int ff_mpa_quant_bits[17];