FFMPEG在windows下编译出错

From Ffmpeg工程组

Jump to: navigation, search

FFMPEG在windows下编译出错 错误如下:

用的是Mingw+Msys
因为想编译出dll,按照ffmpeg的文档
Here are the step-by-step instructions for building the FFmpeg libraries so they can be used with Visual C++: 
Install Visual C++ (if you haven't done so already). 
Install MinGW and MSYS as described above. 
Add a call to `vcvars32.bat' (which sets up the environment variables for the Visual C++ tools) as the first line of
`msys.bat'. The standard location for `vcvars32.bat' is `C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat', and
the standard location for `msys.bat' is `C:\msys\1.0\msys.bat'. If this corresponds to your setup, add the following line as
the first line of `msys.bat': call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" 
Start the MSYS shell (file `msys.bat') and type link.exe. If you get a help message with the command line options of 
link.exe, this means your environment variables are set up correctly, the Microsoft linker is on the path and will be used by
FFmpeg to create Visual-C++-compatible import libraries. 
Extract the current version of FFmpeg and change to the FFmpeg directory. 
Type the command ./configure --enable-shared --disable-static --enable-memalign-hack to configure and, if that didn't produce
any errors, type make to build FFmpeg. 
The subdirectories `libavformat', `libavcodec', and `libavutil' should now contain the files `avformat.dll', `avformat.lib',
`avcodec.dll', `avcodec.lib', `avutil.dll', and `avutil.lib', respectively. Copy the three DLLs to your System32 directory
(typically `C:\Windows\System32'). 
但是make之后出现如下错误
C:/DOCUME~1/Cale/LOCALS~1/Temp/ccKCbaaa.o(.text+0x3d2): In function `main':
f:/Codec/ffmpeg_lh/ffmpeg/qt-faststart.c:152: undefined reference to `fseeko64'
C:/DOCUME~1/Cale/LOCALS~1/Temp/ccKCbaaa.o(.text+0x516):f:/Codec/ffmpeg_lh/ffmpeg/qt-faststart.c:164: undefined reference to 
`fseeko64'
C:/DOCUME~1/Cale/LOCALS~1/Temp/ccKCbaaa.o(.text+0x51e):f:/Codec/ffmpeg_lh/ffmpeg/qt-faststart.c:165: undefined reference to
`ftello64'
C:/DOCUME~1/Cale/LOCALS~1/Temp/ccKCbaaa.o(.text+0x6e5):f:/Codec/ffmpeg_lh/ffmpeg/qt-faststart.c:247: undefined reference to
`fseeko64'
C:/DOCUME~1/Cale/LOCALS~1/Temp/ccKCbaaa.o(.text+0xdc7):f:/Codec/ffmpeg_lh/ffmpeg/qt-faststart.c:133: undefined reference to
`fseeko64'
C:/DOCUME~1/Cale/LOCALS~1/Temp/ccKCbaaa.o(.text+0xdec):f:/Codec/ffmpeg_lh/ffmpeg/qt-faststart.c:140: undefined reference to
`ftello64'
make: *** [qt-faststart.exe] Error 1
在configure的时候加入--enable-mingw32也是同样的错误,换了一台机器还是同样错误,使用4月的ffmpeg版本和6月14日的版本还是同样错误。

解答如下:

应该还是环境的问题。如果不使用qt-faststart的话,最简单的办法,就是把这些64位的函数手工改成32位平台下的对应函数就行了。
换句话说就是没有大于4g的quicktime文件需要转换,用在32位的机器下面就可以采用以下方法:
例如:
出错是在qt-faststart.c里
#ifdef __MINGW32__
#define fseeko(x,y,z)  fseeko64(x,y,z)
#define ftello(x)      ftello64(x)
#endif
只需要把#define fseek(x,y,z) fseeko64(x,y,z)改成:#define fseek(x,y,z)  fseek(x,y,z) 

采用旧的编译环境编译最新的ffmpeg源代码时,会出现如下错误提示:

utils.o:utils.c:(.text+0x4949): undefined reference to `gettimeofday'

解决方案:

You need to update your mingw runtime and probably your w32api to the latest versions. 3.13 and 3.10 respectively as of writing.


有关该问题的讨论帖可参考ffmpeg工程组论坛中的相关讨论:

有关的FFMPEG在windows下编译出错的讨论
Personal tools