@@ -102,53 +102,19 @@ AC_SUBST([FFMPEG_LIBS])
102102CPPFLAGS="$CPPFLAGS -D__STDC_CONSTANT_MACROS"
103103CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
104104
105- AC_DEFUN ( [ TEST_FFMPEG] ,
106- [ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [
107- #include <libavformat/avformat.h>
108- #include <libswscale/swscale.h>
109- ] ] ,[ [
110- avformat_network_init();
111- swscale_version();
112- ] ] ) ] , [ eval $1 =yes] , [ eval $1 =no] )
113- ] )
114-
115- AC_MSG_CHECKING ( [ whether FFmpeg works] )
116- LIBS="$_LIBS $FFMPEG_LIBS"
117- TEST_FFMPEG([ FFMPEG_WORKS] )
118- AC_MSG_RESULT ( [ $FFMPEG_WORKS] )
119- if test "$FFMPEG_WORKS" = no; then
120- AC_MSG_FAILURE ( [ cannot link with FFmpeg] )
121- fi
122-
105+ dnl The -Wl,-Bsymbolic flag is required only when building ffms2 as a shared library against a static build of FFmpeg.
106+ dnl Unfortunately, there is no reliable way to detect whether FFmpeg is static at configure time (especially when using *-uninstalled.pc files).
107+ dnl To avoid unexpected link errors, we always enable it when building shared.
108+ dnl For details, see FFmpeg’s advanced linking notes:https://ffmpeg.org/platform.html#Advanced-linking-configuration
123109src_core_libffms2_la_LDFLAGS=""
124- AC_MSG_CHECKING ( [ whether -Wl,-Bsymbolic is needed] )
125110if test "$enable_shared" = yes; then
126- _LDFLAGS="$LDFLAGS"
127- LDFLAGS="$LDFLAGS -shared $lt_prog_compiler_pic"
128- TEST_FFMPEG([ no_bsymbolic] )
129- if test "$no_bsymbolic" = "no"; then
130- LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
131- TEST_FFMPEG([ bsymbolic] )
132- if test "$bsymbolic" = "yes"; then
133- src_core_libffms2_la_LDFLAGS="$src_core_libffms2_la_LDFLAGS -Wl,-Bsymbolic"
134- else
135- AC_MSG_RESULT ( $bsymbolic )
136- AC_MSG_FAILURE ( [ cannot build ffms2 as a shared library] )
137- fi
138- else
139- bsymbolic=no
140- fi
141- LDFLAGS="$_LDFLAGS"
142- src_core_libffms2_la_LDFLAGS="$src_core_libffms2_la_LDFLAGS -version-info $VERSION_INFO"
143- else
144- bsymbolic=no
111+ AX_CHECK_LINK_FLAG ( [ -Wl,-Bsymbolic] , [ src_core_libffms2_la_LDFLAGS="$src_core_libffms2_la_LDFLAGS -Wl,-Bsymbolic -version-info $VERSION_INFO"] )
145112fi
146113AC_SUBST ( [ src_core_libffms2_la_LDFLAGS] )
147114
148115CFLAGS="$_CFLAGS"
149116CPPFLAGS="$_CPPFLAGS"
150117LIBS="$_LIBS"
151- AC_MSG_RESULT ( $bsymbolic )
152118
153119if echo "$host" | $GREP "mingw" >/dev/null 2>&1; then
154120 LTUNDEF="-no-undefined"
0 commit comments