Go to file
Martin Storsjö d66c52c2b3 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>
2012-10-18 14:26:15 +03:00
compat build: tms470: work around glibc math.h problems 2012-10-13 18:21:36 +01:00
doc nut: support pcm codecs not mapped in avi 2012-10-13 12:33:18 +02:00
libavcodec Add support for building shared libraries with MSVC 2012-10-18 14:26:15 +03:00
libavdevice lavu,lavd: do not use av_pix_fmt_descriptors directly. 2012-10-12 12:45:39 +02:00
libavfilter avfilter: call x86 init functions under if (ARCH_X86), not if (HAVE_MMX) 2012-10-12 19:58:51 +02:00
libavformat gxf: Add a local copy of the relevant parts of the frame rate table 2012-10-18 14:26:13 +03:00
libavresample lavr: handle clipping in the float to s32 conversion 2012-10-13 12:34:34 +02:00
libavutil Add support for building shared libraries with MSVC 2012-10-18 14:26:15 +03:00
libswscale swscale: try to use mmap only if available 2012-10-15 02:39:49 +01:00
presets presets: spelling error in libvpx 1080p50_60 2011-10-22 00:28:56 +02:00
tests fate: list lavfi tests in a makefile 2012-10-17 22:31:18 +01:00
tools tools: do not use av_pix_fmt_descriptors directly. 2012-10-12 12:45:38 +02:00
.gitignore build: change checkheaders to use regular build rules 2012-08-07 21:36:51 +01:00
arch.mak avcodec: Remove broken MMI optimizations 2012-10-12 20:56:54 +02:00
avconv_filter.c De-doxygenize some top-level files 2012-10-12 20:56:54 +02:00
avconv_opt.c avconv: fix disabling auto mappings with -map_metadata 2012-10-16 18:49:59 +02:00
avconv.c De-doxygenize some top-level files 2012-10-12 20:56:54 +02:00
avconv.h De-doxygenize some top-level files 2012-10-12 20:56:54 +02:00
avplay.c avplay: support mid-stream sample rate changes 2012-10-13 00:19:00 -04:00
avprobe.c tools: do not use av_pix_fmt_descriptors directly. 2012-10-12 12:45:38 +02:00
avserver.c avserver: move avserver-specific code from ffmdec.c to avserver.c 2012-10-16 14:20:05 +01:00
Changelog wav muxer: write metadata 2012-10-16 18:51:56 +02:00
cmdutils_common_opts.h cmdutils: extend -h to allow printing codec details. 2012-08-19 19:22:08 +02:00
cmdutils.c tools: do not use av_pix_fmt_descriptors directly. 2012-10-12 12:45:38 +02:00
cmdutils.h Replace PIX_FMT_* -> AV_PIX_FMT_*, PixelFormat -> AVPixelFormat 2012-10-08 07:13:26 +02:00
common.mak build: Properly remove object files while cleaning 2012-09-15 19:44:05 -04:00
configure Add support for building shared libraries with MSVC 2012-10-18 14:26:15 +03:00
COPYING.GPLv2 Rename COPYING.GPL --> COPYING.GPLv2 and COPYING.LGPL --> COPYING.LGPLv2.1. 2009-06-05 09:51:31 +00:00
COPYING.GPLv3 Add configure option to upgrade (L)GPL to version 3. 2009-06-05 11:04:03 +00:00
COPYING.LGPLv2.1 cosmetics: Delete empty lines at end of file. 2012-02-09 12:26:45 +01:00
COPYING.LGPLv3 Add configure option to upgrade (L)GPL to version 3. 2009-06-05 11:04:03 +00:00
CREDITS partially rename FFmpeg to Libav 2011-03-16 21:54:39 +01:00
Doxyfile x86: build: replace mmx2 by mmxext 2012-08-03 22:51:05 +02:00
INSTALL doc: clarify configure features 2011-04-07 02:54:12 +02:00
library.mak build: do not use LIB as variable name 2012-10-10 23:46:31 +01:00
LICENSE doc: Clarify licensing issues arising from external libraries 2012-08-12 13:28:58 +02:00
Makefile build: simplify linking tools with cmdutils.o 2012-10-15 22:28:07 +01:00
README cosmetics: fix dashed line length after 070c5d0 2011-03-28 09:53:40 +02:00
RELEASE prepare 9_beta1 release 2012-10-11 18:36:40 +02:00
version.sh Drop git- prefix from version labels 2011-06-19 19:41:23 +01:00

Libav README
------------

1) Documentation
----------------

* Read the documentation in the doc/ directory.

2) Licensing
------------

* See the LICENSE file.