[FFmpeg-devel] [PATCH] Shared library support for MSVC build.
jamal
jamrial at gmail.com
Wed Oct 3 05:59:51 CEST 2012
On 02/10/12 9:48 PM, Ronald S. Bultje wrote:
> From: "Ronald S. Bultje" <rsbultje at gmail.com>
>
> diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
> index d6e0eed..0063c8d 100644
> --- a/libavcodec/ac3tab.h
> +++ b/libavcodec/ac3tab.h
> @@ -24,6 +24,7 @@
>
> #include "libavutil/common.h"
> #include "ac3.h"
> +#include "symbols.h"
>
> #if CONFIG_HARDCODED_TABLES
> # define HCONST const
> diff --git a/libavcodec/symbols.h b/libavcodec/symbols.h
> new file mode 100644
> index 0000000..ca4a89d
> --- /dev/null
> +++ b/libavcodec/symbols.h
> @@ -0,0 +1,32 @@
> +/*
> + * Copyright (c) 2012 Ronald S. Bultje <rsbultje at gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVCODEC_SYMBOLS_H
> +#define AVCODEC_SYMBOLS_H
> +
> +#include "libavutil/avconfig.h"
> +
> +#if AV_HAVE_SHARED_LIBS && defined(_MSC_VER) && !defined(COMPILING_avcodec)
> +#define AVCODEC_SYMBOL __declspec(dllimport)
> +#else
> +#define AVCODEC_SYMBOL
> +#endif
> +
> +#endif /* AVCODEC_SYMBOLS_H */
> diff --git a/libavutil/sha.h b/libavutil/sha.h
> index d891cae..62e4edf 100644
> --- a/libavutil/sha.h
> +++ b/libavutil/sha.h
> @@ -23,13 +23,15 @@
>
> #include <stdint.h>
>
> +#include "symbols.h"
> +
> /**
> * @defgroup lavu_sha SHA
> * @ingroup lavu_crypto
>
> diff --git a/libavutil/symbols.h b/libavutil/symbols.h
> new file mode 100644
> index 0000000..6011da2
> --- /dev/null
> +++ b/libavutil/symbols.h
> @@ -0,0 +1,32 @@
> +/*
> + * Copyright (c) 2012 Ronald S. Bultje <rsbultje at gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVUTIL_SYMBOLS_H
> +#define AVUTIL_SYMBOLS_H
> +
> +#include "libavutil/avconfig.h"
> +
> +#if AV_HAVE_SHARED_LIBS && defined(_MSC_VER) && !defined(COMPILING_avutil)
> +#define AVUTIL_SYMBOL __declspec(dllimport)
> +#else
> +#define AVUTIL_SYMBOL
> +#endif
> +
> +#endif /* AVUTIL_SYMBOLS_H */
You're doing what you mentioned you wanted to avoid the other day: Create a header for essentially a single purpose/platform and include it in those files that would require it.
__declspec() is an attribute, so you could instead add it to libavutil/attributes.h to more or less avoid that, since it's a widely used header.
Regards.
More information about the ffmpeg-devel
mailing list