Opened 12 years ago

Closed 12 years ago

Last modified 9 years ago

#282 closed defect (invalid)

undefined reference to `_avdevice_register_all'

Reported by: Kyle Owned by: Michael Niedermayer
Priority: critical Component: build system
Version: git Keywords: undefined reference avdevice_register_all
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


I'm getting:

ffmpeg.c:4514: undefined reference to `_avdevice_register_all'

when --disable-static --enable-shared is used, it seems to only happen when --disable-static --enable-shared is used, static builds fine.

I believe it is related to the leading underscore _ before avdevice_register_all but I can't confirm that.

I'm building for Windows and the toolchain is not the issue.

I gave this a critical priority because FFmpeg will not build a shared version for Windows.

I'm unsure of what patch broke this, but the last proven working build I know of is git-39dbe9b.

Attachments (1)

config.log (173.3 KB ) - added by Kyle 12 years ago.

Download all attachments as: .zip

Change History (34)

comment:1 by Carl Eugen Hoyos, 12 years ago

Component: FFmpegbuild system
Status: newopen

Please confirm that you are using latest git head (first line of "git show"), that you did "make distclean && ./configure --disable-static --enable-shared && make ffmpeg" and if it still fails, please run "make ffmpeg" again, then run "make V=1 ffmpeg" and post the complete, uncut output of this last run (and consider attaching config.log).

comment:2 by Kyle, 12 years ago

The problem is SDL/ffplay related. I narrowed it down and the issue only occurs when ffplay is built, along with --disable-static --enable-shared.

also, the command you gave me "make ffmpeg" is not valid, I'm not sure if it's a windows thing or what, but I think you might have meant "make ffmpeg.o" but I'm not going to assume anything.

Here is "make V=1":

i686-w64-mingw32-gcc -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavutil -Llibpostproc -Llibswscale -L/home/kyle/software/ffmpeg/packages/sdl/sdl-1.2.14-win32/lib -Wl,--as-needed -Wl,--warn-common -Wl,-rpath-link,libpostproc -Wl,-rpath-link,libswscale -Wl,-rpath-link,libavfilter -Wl,-rpath-link,libavdevice -Wl,-rpath-link,libavformat -Wl,-rpath-link,libavcodec -Wl,-rpath-link,libavutil -o ffmpeg_g.exe ffmpeg.o cmdutils.o -lavdevice -lavfilter -lavformat -lavcodec -lpostproc -lswscale -lavutil -lavicap32 -lpsapi -lole32 -lstrmiids -luuid -lws2_32 -L/home/kyle/software/ffmpeg/packages/sdl/sdl-1.2.14-win32/lib -lmingw32 -lSDLmain -lSDL -lm -luser32 -lgdi32 -lwinmm -ldxguid -lm -lpthreadGC2 -lpsapi 
ffmpeg.o: In function `main':
/home/kyle/software/ffmpeg/source/ffmpeg-git/ffmpeg.c:4525: undefined reference to `_avdevice_register_all'
cmdutils.o: In function `print_all_libs_info':
/home/kyle/software/ffmpeg/source/ffmpeg-git/cmdutils.c:514: undefined reference to `_avdevice_configuration'
/home/kyle/software/ffmpeg/source/ffmpeg-git/cmdutils.c:514: undefined reference to `_avdevice_version'
collect2: ld returned 1 exit status
make: *** [ffmpeg_g.exe] Error 1

As I said, it only happens with --disable-static --enable-shared and it's ffplay/sdl related I believe.

comment:3 by Carl Eugen Hoyos, 12 years ago

1) confirm that you are using latest git
2) confirm that you did "make distclean" before trying anything else
3) provide your complete configure line
4) attach config log

(Note that ./configure --disable-static --enable-shared works fine here and that you say your problem is ffplay-related, but you provide a failing link command for ffmpeg.)

by Kyle, 12 years ago

Attachment: config.log added

comment:4 by Kyle, 12 years ago

1) I'm using the latest git, 4f643430f295a8376ca51f127a23b0f8ce92068b
2) I build out of the source directory, the build directory is removed and rebuilt before configure is run.
3) LDFLAGS="-L/home/kyle/software/ffmpeg/packages/sdl/sdl-1.2.14-win32/lib" PKG_CONFIG_PATH="/home/kyle/software/ffmpeg/packages/sdl/sdl-1.2.14-win32/lib/pkgconfig" CFLAGS="-I/home/kyle/software/ffmpeg/packages/sdl/sdl-1.2.14-win32/include" cross_prefix=i686-w64-mingw32- target_os=mingw32 arch=x86 ../source/ffmpeg-git/configure --disable-static --enable-shared --enable-gpl --enable-version3 --enable-memalign-hack --enable-runtime-cpudetect
4) Attached.

Yes I realize that it is a failing link command for ffmpeg, but the issue only occurs when sdl is in the LDFLAGS and CFLAGS, meaning it only occurs when FFmpeg is able to build ffplay.

comment:5 by Carl Eugen Hoyos, 12 years ago

Could you try to use --extra-cflags and --extra-ldflags instead of CFLAGS and LDFLAGS?

comment:6 by Kyle, 12 years ago

I get the same error with --extra-cflags and --extra-ldflags instead of CFLAGS and LDFLAGS.

comment:7 by Carl Eugen Hoyos, 12 years ago

If you think this is a regression, perhaps you find the version introducing it?

comment:8 by Kyle, 12 years ago

It was introduced with commit 2291e18e4891066bbcbcd1a4e468a59a40e9cb5c which can be found at:;a=commit;h=2291e18e4891066bbcbcd1a4e468a59a40e9cb5c

The commit before it, 151c5841881591552be685b7fd50b488f128ba5b does build.

Something in rawdec.o must be causing the issue, I believe the issue is the leading underscore.

comment:9 by Kyle, 12 years ago

After doing some more reading it might not be rawdec.o, it appears that;a=patch;h=2291e18e4891066bbcbcd1a4e468a59a40e9cb5c (the patch) doesn't actually display all the changes in that commit.

When doing a diff comparison between the libavcodec Makefile in 151c5841881591552be685b7fd50b488f128ba5b and 2291e18e4891066bbcbcd1a4e468a59a40e9cb5c I get many more changes:

--- /home/kyle/software/ffmpeg/source/ffmpeg-151c584/libavcodec/Makefile	2011-06-11 15:35:53.000000000 -0400
+++ /home/kyle/software/ffmpeg/source/ffmpeg-2291e18/libavcodec/Makefile	2011-06-11 21:04:07.000000000 -0400
@@ -18,6 +18,7 @@
        options.o                                                        \
        parser.o                                                         \
        raw.o                                                            \
+       rawdec.o                                                         \
        resample.o                                                       \
        resample2.o                                                      \
        simple_idct.o                                                    \
@@ -26,6 +27,7 @@
 # parts needed for many different codecs
 OBJS-$(CONFIG_AANDCT)                  += aandcttab.o
 OBJS-$(CONFIG_AC3DSP)                  += ac3dsp.o
+OBJS-$(CONFIG_CRYSTALHD)               += crystalhd.o
 OBJS-$(CONFIG_ENCODERS)                += faandct.o jfdctfst.o jfdctint.o
 OBJS-$(CONFIG_DCT)                     += dct.o dct32_fixed.o dct32_float.o
 OBJS-$(CONFIG_DWT)                     += dwt.o
@@ -60,7 +62,8 @@
                                           mpeg4audio.o kbdwin.o
 OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
 OBJS-$(CONFIG_AC3_DECODER)             += ac3dec.o ac3dec_data.o ac3.o kbdwin.o
-OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3tab.o ac3.o kbdwin.o
+OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_combined.o ac3enc_fixed.o ac3enc_float.o ac3tab.o ac3.o kbdwin.o
+OBJS-$(CONFIG_AC3_FLOAT_ENCODER)       += ac3enc_float.o ac3tab.o ac3.o kbdwin.o
 OBJS-$(CONFIG_AC3_FIXED_ENCODER)       += ac3enc_fixed.o ac3tab.o ac3.o
 OBJS-$(CONFIG_ALAC_DECODER)            += alac.o
 OBJS-$(CONFIG_ALAC_ENCODER)            += alacenc.o
@@ -77,7 +80,7 @@
 OBJS-$(CONFIG_ANM_DECODER)             += anm.o
 OBJS-$(CONFIG_ANSI_DECODER)            += ansi.o cga_data.o
 OBJS-$(CONFIG_APE_DECODER)             += apedec.o
-OBJS-$(CONFIG_ASS_DECODER)             += assdec.o ass.o
+OBJS-$(CONFIG_ASS_DECODER)             += assdec.o ass.o ass_split.o
 OBJS-$(CONFIG_ASS_ENCODER)             += assenc.o ass.o
 OBJS-$(CONFIG_ASV1_DECODER)            += asv1.o mpeg12data.o
 OBJS-$(CONFIG_ASV1_ENCODER)            += asv1.o mpeg12data.o
@@ -106,6 +109,7 @@
 OBJS-$(CONFIG_CSCD_DECODER)            += cscd.o
 OBJS-$(CONFIG_CYUV_DECODER)            += cyuv.o
 OBJS-$(CONFIG_DCA_DECODER)             += dca.o synth_filter.o dcadsp.o
+OBJS-$(CONFIG_DCA_ENCODER)             += dcaenc.o
 OBJS-$(CONFIG_DFA_DECODER)             += dfa.o
 OBJS-$(CONFIG_DNXHD_DECODER)           += dnxhddec.o dnxhddata.o
 OBJS-$(CONFIG_DNXHD_ENCODER)           += dnxhdenc.o dnxhddata.o       \
@@ -138,15 +142,17 @@
 OBJS-$(CONFIG_ESCAPE124_DECODER)       += escape124.o
 OBJS-$(CONFIG_FFV1_DECODER)            += ffv1.o rangecoder.o
 OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1.o rangecoder.o
 OBJS-$(CONFIG_FFVHUFF_DECODER)         += huffyuv.o
 OBJS-$(CONFIG_FFVHUFF_ENCODER)         += huffyuv.o
-OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o flacdata.o flac.o
-OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o flacdata.o flac.o vorbis_data.o
+OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o vorbis_data.o
 OBJS-$(CONFIG_FLASHSV_DECODER)         += flashsv.o
 OBJS-$(CONFIG_FLASHSV_ENCODER)         += flashsvenc.o
+OBJS-$(CONFIG_FLASHSV2_ENCODER)        += flashsv2enc.o
 OBJS-$(CONFIG_FLIC_DECODER)            += flicvideo.o
 OBJS-$(CONFIG_FOURXM_DECODER)          += 4xm.o
 OBJS-$(CONFIG_FRAPS_DECODER)           += fraps.o
@@ -171,7 +177,7 @@
                                           ratecontrol.o h263.o ituh263enc.o \
                                           flvenc.o mpeg12data.o             \
                                           mpegvideo.o error_resilience.o
-OBJS-$(CONFIG_H264_DECODER)            += h264.o                               \
+OBJS-$(CONFIG_H264_DECODER)            += h264.o h264_hl_motion.o              \
                                           h264_loopfilter.o h264_direct.o      \
                                           cabac.o h264_sei.o h264_ps.o         \
                                           h264_refs.o h264_cavlc.o h264_cabac.o\
@@ -189,6 +195,8 @@
 OBJS-$(CONFIG_INDEO5_DECODER)          += indeo5.o ivi_common.o ivi_dsp.o
+OBJS-$(CONFIG_JPEG2000_DECODER)        += j2kdec.o mqcdec.o mqc.o j2k.o j2k_dwt.o
+#OBJS-$(CONFIG_JPEG2000_ENCODER)        += j2kenc.o mqcenc.o mqc.o j2k.o j2k_dwt.o
 OBJS-$(CONFIG_JPEGLS_DECODER)          += jpeglsdec.o jpegls.o \
                                           mjpegdec.o mjpeg.o
 OBJS-$(CONFIG_JPEGLS_ENCODER)          += jpeglsenc.o jpegls.o
@@ -274,6 +282,7 @@
                                           h263.o ituh263dec.o mpeg4videodec.o
 OBJS-$(CONFIG_MSRLE_DECODER)           += msrle.o msrledec.o
 OBJS-$(CONFIG_MSVIDEO1_DECODER)        += msvideo1.o
+OBJS-$(CONFIG_MSVIDEO1_ENCODER)        += msvideo1enc.o elbg.o
 OBJS-$(CONFIG_MSZH_DECODER)            += lcldec.o
 OBJS-$(CONFIG_MXPEG_DECODER)           += mxpegdec.o mjpegdec.o mjpeg.o
 OBJS-$(CONFIG_NELLYMOSER_DECODER)      += nellymoserdec.o nellymoser.o
@@ -345,8 +354,12 @@
                                           ituh263enc.o mpegvideo_enc.o     \
 OBJS-$(CONFIG_SOL_DPCM_DECODER)        += dpcm.o
+OBJS-$(CONFIG_SONIC_DECODER)           += sonic.o
+OBJS-$(CONFIG_SONIC_ENCODER)           += sonic.o
+OBJS-$(CONFIG_SONIC_LS_ENCODER)        += sonic.o
 OBJS-$(CONFIG_SP5X_DECODER)            += sp5xdec.o mjpegdec.o mjpeg.o
 OBJS-$(CONFIG_SRT_DECODER)             += srtdec.o ass.o
+OBJS-$(CONFIG_SRT_ENCODER)             += srtenc.o ass_split.o
 OBJS-$(CONFIG_SUNRAST_DECODER)         += sunrast.o
 OBJS-$(CONFIG_SVQ1_DECODER)            += svq1dec.o svq1.o h263.o \
                                           mpegvideo.o error_resilience.o
@@ -355,7 +368,7 @@
                                           mpegvideo.o error_resilience.o \
                                           ituh263enc.o mpegvideo_enc.o   \
                                           ratecontrol.o mpeg12data.o
-OBJS-$(CONFIG_SVQ3_DECODER)            += h264.o svq3.o                       \
+OBJS-$(CONFIG_SVQ3_DECODER)            += h264.o svq3.o h264_hl_motion.o      \
                                           h264_loopfilter.o h264_direct.o     \
                                           h264_sei.o h264_ps.o h264_refs.o    \
                                           h264_cavlc.o h264_cabac.o cabac.o   \
@@ -526,33 +539,35 @@
 OBJS-$(CONFIG_CAF_DEMUXER)             += mpeg4audio.o mpegaudiodata.o
 OBJS-$(CONFIG_DV_DEMUXER)              += dvdata.o
 OBJS-$(CONFIG_DV_MUXER)                += dvdata.o
-OBJS-$(CONFIG_FLAC_DEMUXER)            += flacdec.o flacdata.o flac.o
-OBJS-$(CONFIG_FLAC_MUXER)              += flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_DEMUXER)            += flacdec.o flacdata.o flac.o vorbis_data.o
+OBJS-$(CONFIG_FLAC_MUXER)              += flacdec.o flacdata.o flac.o vorbis_data.o
 OBJS-$(CONFIG_FLV_DEMUXER)             += mpeg4audio.o
 OBJS-$(CONFIG_GXF_DEMUXER)             += mpeg12data.o
 OBJS-$(CONFIG_IFF_DEMUXER)             += iff.o
-OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)    += xiph.o mpeg4audio.o \
+OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)    += xiph.o mpeg4audio.o vorbis_data.o \
                                           flacdec.o flacdata.o flac.o
 OBJS-$(CONFIG_MATROSKA_DEMUXER)        += mpeg4audio.o mpegaudiodata.o
 OBJS-$(CONFIG_MATROSKA_MUXER)          += xiph.o mpeg4audio.o \
                                           flacdec.o flacdata.o flac.o \
-                                          mpegaudiodata.o
+                                          mpegaudiodata.o vorbis_data.o
 OBJS-$(CONFIG_MOV_DEMUXER)             += mpeg4audio.o mpegaudiodata.o
 OBJS-$(CONFIG_MOV_MUXER)               += mpeg4audio.o mpegaudiodata.o
 OBJS-$(CONFIG_MPEGTS_MUXER)            += mpegvideo.o mpeg4audio.o
 OBJS-$(CONFIG_MPEGTS_DEMUXER)          += mpeg4audio.o mpegaudiodata.o
 OBJS-$(CONFIG_NUT_MUXER)               += mpegaudiodata.o
 OBJS-$(CONFIG_OGG_DEMUXER)             += flacdec.o flacdata.o flac.o \
-                                          dirac.o mpeg12data.o
-OBJS-$(CONFIG_OGG_MUXER)               += xiph.o flacdec.o flacdata.o flac.o
+                                          dirac.o mpeg12data.o vorbis_data.o
+OBJS-$(CONFIG_OGG_MUXER)               += xiph.o flacdec.o flacdata.o flac.o \
+                                          vorbis_data.o
 OBJS-$(CONFIG_RTP_MUXER)               += mpeg4audio.o mpegvideo.o xiph.o
 OBJS-$(CONFIG_SPDIF_DEMUXER)           += aacadtsdec.o mpeg4audio.o
 OBJS-$(CONFIG_WEBM_MUXER)              += xiph.o mpeg4audio.o \
                                           flacdec.o flacdata.o flac.o \
-                                          mpegaudiodata.o
+                                          mpegaudiodata.o vorbis_data.o
 OBJS-$(CONFIG_WTV_DEMUXER)             += mpeg4audio.o mpegaudiodata.o
 # external codec libraries
+OBJS-$(CONFIG_LIBCELT_DECODER)            += libcelt_dec.o
 OBJS-$(CONFIG_LIBDIRAC_DECODER)           += libdiracdec.o
 OBJS-$(CONFIG_LIBDIRAC_ENCODER)           += libdiracenc.o libdirac_libschro.o
 OBJS-$(CONFIG_LIBFAAC_ENCODER)            += libfaac.o
@@ -593,10 +608,11 @@
 OBJS-$(CONFIG_DNXHD_PARSER)            += dnxhd_parser.o
 OBJS-$(CONFIG_DVBSUB_PARSER)           += dvbsub_parser.o
 OBJS-$(CONFIG_DVDSUB_PARSER)           += dvdsub_parser.o
-OBJS-$(CONFIG_FLAC_PARSER)             += flac_parser.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_PARSER)             += flac_parser.o flacdata.o flac.o \
+                                          vorbis_data.o
 OBJS-$(CONFIG_H261_PARSER)             += h261_parser.o
 OBJS-$(CONFIG_H263_PARSER)             += h263_parser.o
-OBJS-$(CONFIG_H264_PARSER)             += h264_parser.o h264.o            \
+OBJS-$(CONFIG_H264_PARSER)             += h264_parser.o h264.o h264_hl_motion.o \
                                           cabac.o                         \
                                           h264_refs.o h264_sei.o h264_direct.o \
                                           h264_loopfilter.o h264_cabac.o \
@@ -665,8 +681,6 @@
 SKIPHEADERS-$(CONFIG_VDPAU)            += vdpau.h
 SKIPHEADERS-$(CONFIG_XVMC)             += xvmc.h
 TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder snow
 TESTPROGS-$(HAVE_MMX) += motion
 TESTOBJS = dctref.o

If someone could explain to me why this is that would be nice, does it have to do with the "parent"? I'm only viewing the log:;a=log and comparing each entry.

in reply to:  8 comment:10 by Michael Niedermayer, 12 years ago

Replying to KSHawkEye:

It was introduced with commit 2291e18e4891066bbcbcd1a4e468a59a40e9cb5c which can be found at:;a=commit;h=2291e18e4891066bbcbcd1a4e468a59a40e9cb5c

The commit before it, 151c5841881591552be685b7fd50b488f128ba5b does build.

This commit is not a ancestor of 2291e18e4891066bbcbcd1a4e468a59a40e9cb5c

you can see with git graph that they are on seperate branches

please try git bisect

in reply to:  description comment:11 by Michael Niedermayer, 12 years ago

Replying to KSHawkEye:

I believe it is related to the leading underscore _ before avdevice_register_all but I can't confirm that.

can you confirm that the function name referenced in the .o file when its working does not have the initial _ ?

comment:12 by Kyle, 12 years ago

Actually, in ffmpeg.o it does have the _

U _avdevice_register_all

comment:13 by Michael Niedermayer, 12 years ago

So do you have any idea what is causing this ?
maybe you can look at the compile/link flags between working and non working and find out which is
causing this. If its the flags that cause this ...

comment:14 by Michael Niedermayer, 12 years ago

Also a in the future a mingw fate client would help detecting such breakage early

comment:15 by Kyle, 12 years ago

Here are the differences in the compile flags:

i686-w64-mingw32-gcc -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavutil -Llibpostproc -Llibswscale -L/home/kyle/software/ffmpeg/packages/sdl/sdl-1.2.14-win32/lib -Wl,--as-needed -Wl,--warn-common -Wl,-rpath-link,libpostproc -Wl,-rpath-link,libswscale -Wl,-rpath-link,libavfilter -Wl,-rpath-link,libavdevice -Wl,-rpath-link,libavformat -Wl,-rpath-link,libavcodec -Wl,-rpath-link,libavutil -o ffmpeg.exe ffmpeg.o cmdutils.o -lavdevice -lavfilter -lavformat -lavcodec -lswscale -lavutil -lavicap32 -lws2_32 -lm -lpthreadGC2 -lpsapi

Not working:
i686-w64-mingw32-gcc -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavutil -Llibpostproc -Llibswscale -L/home/kyle/software/ffmpeg/packages/sdl/sdl-1.2.14-win32/lib -Wl,--as-needed -Wl,--warn-common -Wl,-rpath-link,libpostproc -Wl,-rpath-link,libswscale -Wl,-rpath-link,libavfilter -Wl,-rpath-link,libavdevice -Wl,-rpath-link,libavformat -Wl,-rpath-link,libavcodec -Wl,-rpath-link,libavutil -o ffmpeg_g.exe ffmpeg.o cmdutils.o -lavdevice -lavfilter -lavformat -lavcodec -lswscale -lavutil -lavicap32 -lpsapi -lole32 -lstrmiids -luuid -lws2_32 -L/home/kyle/software/ffmpeg/packages/sdl/sdl-1.2.14-win32/lib -lmingw32 -lSDLmain -lSDL -lm -luser32 -lgdi32 -lwinmm -ldxguid -lm -lpthreadGC2 -lpsapi

As you can see there are a few minor differences, though trying the working one on the non working build I still get the same error.

comment:16 by Michael Niedermayer, 12 years ago

Please try --disable-outdev=sdl

If that doesnt help please provide config.mak/config.h of working and non working also make sure that the working version is from the ffmpeg and not libav branch.


comment:17 by Kyle, 12 years ago

With --disable-outdev=sdl the build does work.

comment:18 by Kyle, 12 years ago

It should also be noted that with that flag ffplay is not built.

in reply to:  18 comment:19 by Michael Niedermayer, 12 years ago

Replying to KSHawkEye:

It should also be noted that with that flag ffplay is not built.

This is very strange and I cant reproduce this on linux.
please provide config.log/mak and make sure its really the addition of this flag that breaks ffplay

comment:20 by Kyle, 12 years ago

Sorry, I guess it was my mistake, I couldn't find it the first time I tried --disable-outdev=sdl.

ffplay is built with the latest git.

comment:21 by Kyle, 12 years ago

Just to clarify, ffplay does build with the latest git, but --disable-outdev=sdl needs to be added

comment:22 by Carl Eugen Hoyos, 12 years ago

I installed latest mingw32 and SDL 1.2.14 on Vista and compiled FFmpeg with --enable-shared --disable-static and the resulting ffplay works fine. (I did not have to disable sdl-output.)

comment:23 by Kyle, 12 years ago

In that case it might be a MinGW-w64 issue.

In any case, I have experienced many more issues with mingw32 then I ever have with MinGW-w64, and the issue can be fixed through FFmpeg seeing that it used to work before.

I would really like to get this bug resolved, and am open to any suggestions that might fix it.

comment:24 by Kyle, 12 years ago

A possible solution can be found here:

Here is a patch that can fix the issue but I have NOT been able to test if this breaks the build for Linux.

--- ./libavdevice/avdevice.h.orig	2011-09-12 02:57:25.891985547 -0400
+++ ./libavdevice/avdevice.h	2011-09-12 03:07:37.140582012 -0400
@@ -41,12 +41,12 @@
  * Return the LIBAVDEVICE_VERSION_INT constant.
-unsigned avdevice_version(void);
+__declspec(dllexport) unsigned avdevice_version(void);
  * Return the libavdevice build-time configuration.
-const char *avdevice_configuration(void);
+__declspec(dllexport) const char *avdevice_configuration(void);
  * Return the libavdevice license.
@@ -57,7 +57,7 @@
  * Initialize libavdevice and register all the input and output devices.
  * @warning This function is not thread safe.
-void avdevice_register_all(void);
+__declspec(dllexport) void avdevice_register_all(void);

I'm open to a different solution to this problem, but would really like to get this bug closed.

comment:25 by Kyle, 12 years ago

This issue can be resolved by compiling SDL with -DDECLSPEC= added to the CFLAGS.

Bug resolved.

comment:26 by Carl Eugen Hoyos, 12 years ago

Resolution: invalid
Status: openclosed

Thank you for the analysis!

comment:27 by Roger Pack, 10 years ago

Thanks for finding the fix--this fixed it here for me, too. So what exactly was this causing? Just wondering how SDL's DECLSPEC affected it. Thanks!

Last edited 10 years ago by Roger Pack (previous) (diff)

comment:28 by reimar, 10 years ago

I do not see any reasonable explanation, and I cannot reproduce it.
However what seems to happen according to the reported facts is that avdevice_register_all is not exported from avdevice-54.dll.
You can check that by running objdump -x libavdevice/avdevice-54.dll
The interesting part is "The Export Tables (interpreted .edata section contents)"
If it was generated correctly, it should have a part looking like this:

[Ordinal/Name Pointer] Table
        [   0] avdevice_configuration
        [   1] avdevice_license
        [   2] avdevice_register_all
        [   3] avdevice_version

The previous suggested hack of adding declspec(dllexport) should not be necessary, the information that these and only these functions should be exported comes from libavdevice/libavdevice.ver.
That file in turn is generated from libavdevice/libavdevice.v.
It is specified via the -Wl,--version-script,libavdevice/libavdevice.ver option when linking the dll file.
This compilation step also generates a libavdevice/avdevice-54.def which should look like this:

    avdevice_configuration @1
    avdevice_license @2
    avdevice_register_all @3
    avdevice_version @4

There is one very crazy theory how this could go wrong with SDL: Without setting -DDECLSPEC SDL will use dllspec(dllexport) and dllspec(dllimport) instead of version/def/dll.a files.
This might mean that the linker ends up with some symbols being marked up via dllspec while also getting a version script, and due to some bug it might end up ignoring the version script.
It seems very unlikely though, but if you want to investigate you will probably want to experiment with the commandline used to link the avdevice dll.

comment:29 by Roger Pack, 10 years ago

$ cat sandbox/win32/ffmpeg_git/libavcodec/*.def
    _ZN6CCodec14CreateInstanceEjPKc @1
    _ZN6CCodec14DeleteInstanceEPS_ @2

These methods come from the "utvideo" package, I believe. So it must be leaking symbols. According to unless --export-all-symbols is explicitly stated, if any symbol is found that is marked with marked with the declspec(dllexport) then it won't export "any other symbols" which must be happening here. Maybe to avoid this type of rampant confusion --export-all-symbols could be added...

Will keep investigating...

comment:30 by reimar, 10 years ago

Why are you looking at libavcodec when the issue is with libavdevice?
Either way, the information in the version script is supposed to be treated the same as dllexport in the source code.
And you certainly don't want to export all symbols, that is likely to come at a significant cost in code size and performance.

comment:31 by reimar, 10 years ago

Just read the documentation on the version-script option:

           It is partially supported on PE platforms, which can use version scripts to filter symbol
           visibility in auto-export mode: any symbols marked local in the version script will not be exported.

That seems to indicate that it ignores which symbols are marked as "global".
At the same time, while not documented, it seems like --export-all-symbols does not override the "local" settings in the version file, so adding that might indeed be a workaround (though the whole behaviour seems broken to me, and contradicts the documentation which suggests that version-script should be ignored when not using auto-export mode).
However that brings me to another point, that I think the libSDL/utvideo build systems are broken.
I presume you link against a static build of these libraries.
However, when building static libraries they should not mark those functions as "dllexport", as the name says it is supposed to be for when you build DLLs.
You certainly don't want these functions to be exported when you just use the functionality.
For example, if the SDL DLL was build statically against utvideo (of course not the case, just an example) it would end up exporting the utvideo functions, which would then cause symbol collisions if an application would try to use both the SDL DLL and a utvideo DLL.

Last edited 10 years ago by reimar (previous) (diff)

comment:32 by Roger Pack, 10 years ago

Yeah my new work around is to patch utvideo so that it doesn't export these (basically wrong) symbols. The failure was occurring when building libavformat-54.dll (which was missing some dependencies from libavcodec.dll, which had previously built poorly, apparently).

comment:33 by Roger Pack, 9 years ago

(for followers, this or similar errors meant "The avcodec-55.def file created for a shared avcodec-55.dll in the ffmpeg libavcodec directory is created wrong with just defines from some other library that wasn't built static, which makes it only pick up those for some reason and so the def file is wrong. This causes the other dlls in ffmpeg to not be created when linking against it.)

Note: See TracTickets for help on using tickets.