From: Steven Walters Date: Thu, 29 Mar 2012 01:15:04 +0000 (-0400) Subject: ICL/MSVS: Fix shared library generation and usage X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=35cf912671fddcb3e701bf667a75f77dd8b28264;p=x264.git ICL/MSVS: Fix shared library generation and usage MSVS requires exported variables to be declared with the DATA keyword, and requires that imported variables be declared with dllimport. This does not fix x264 cli being unable to use a shared library built by ICL however. --- diff --git a/configure b/configure index 16970b83..d527e8ff 100755 --- a/configure +++ b/configure @@ -1091,7 +1091,10 @@ if [ "$shared" = "yes" ]; then # MSVC link does not act similarly, so it is required to make an export definition out of x264.h and use it at link time echo "SOFLAGS=-dll -def:x264.def -implib:\$(IMPLIBNAME) $SOFLAGS" >> config.mak echo "EXPORTS" > x264.def - grep "^\(int\|void\|x264_t\|extern\).*x264.*[\[(;]" ${SRCPATH}/x264.h | sed -e "s/.*\(x264.*\)[\[(].*/\1/;s/.*\(x264.*\);/\1/;s/open/open_$API/g" >> x264.def + # export API functions + grep "^\(int\|void\|x264_t\).*x264" ${SRCPATH}/x264.h | sed -e "s/.*\(x264.*\)(.*/\1/;s/open/open_$API/g" >> x264.def + # export API variables/data. must be flagged with the DATA keyword + grep "extern.*x264" ${SRCPATH}/x264.h | sed -e "s/.*\(x264\w*\)\W.*/\1 DATA/;" >> x264.def else echo 'IMPLIBNAME=libx264.dll.a' >> config.mak echo "SOFLAGS=-shared -Wl,--out-implib,\$(IMPLIBNAME) -Wl,--enable-auto-image-base $SOFLAGS" >> config.mak diff --git a/x264.h b/x264.h index efc61bc0..92191147 100644 --- a/x264.h +++ b/x264.h @@ -41,7 +41,18 @@ #include "x264_config.h" -#define X264_BUILD 122 +#define X264_BUILD 123 + +/* Application developers planning to link against a shared library version of + * libx264 from a Microsoft Visual Studio or similar development environment + * will need to define X264_API_IMPORTS before including this header. + * This clause does not apply to MinGW, similar development environments, or non + * Windows platforms. */ +#ifdef X264_API_IMPORTS +#define X264_API __declspec(dllimport) +#else +#define X264_API +#endif /* x264_t: * opaque handler for encoder */ @@ -516,7 +527,7 @@ typedef struct } x264_level_t; /* all of the levels defined in the standard, terminated by .level_idc=0 */ -extern const x264_level_t x264_levels[]; +X264_API extern const x264_level_t x264_levels[]; /**************************************************************************** * Basic parameter handling functions @@ -613,14 +624,14 @@ int x264_param_apply_profile( x264_param_t *, const char *profile ); * (16-x264_bit_depth) bits to be zero. * Note: The flag X264_CSP_HIGH_DEPTH must be used to specify the * colorspace depth as well. */ -extern const int x264_bit_depth; +X264_API extern const int x264_bit_depth; /* x264_chroma_format: * Specifies the chroma formats that x264 supports encoding. When this * value is non-zero, then it represents a X264_CSP_* that is the only * chroma format that x264 supports encoding. If the value is 0 then * there are no restrictions. */ -extern const int x264_chroma_format; +X264_API extern const int x264_chroma_format; enum pic_struct_e {