在有的时候使用VC开发环境链接ffmpeg库文件后,生成的文件无法运行,这有可能是由于.lib文件与.dll文件不匹配造成的。
使用VC开发环境提供的lib.exe工具通过*.def文件重新生成*.lib文件,批处理命令示例如下:
@echo off cd\ c: cd C:\Program Files\Microsoft Visual Studio 10.0\VC call vcvarsall.bat @rem 这里设置win32 def文件目录 SET ffmpeglibpath=G:\ffmpeg-1.2\win32\lib lib /MACHINE:X86 /DEF:%ffmpeglibpath%\avcodec-54.def /OUT:%ffmpeglibpath%\avcodec.lib lib /MACHINE:X86 /DEF:%ffmpeglibpath%\avformat-54.def /OUT:%ffmpeglibpath%\avformat.lib lib /MACHINE:X86 /DEF:%ffmpeglibpath%\avutil-52.def /OUT:%ffmpeglibpath%\avutil.lib lib /MACHINE:X86 /DEF:%ffmpeglibpath%\avfilter-3.def /OUT:%ffmpeglibpath%\avfilter.lib lib /MACHINE:X86 /DEF:%ffmpeglibpath%\avdevice-54.def /OUT:%ffmpeglibpath%\avdevice.lib lib /MACHINE:X86 /DEF:%ffmpeglibpath%\swscale-2.def /OUT:%ffmpeglibpath%\swscale.lib lib /MACHINE:X86 /DEF:%ffmpeglibpath%\swresample-0.def /OUT:%ffmpeglibpath%\swresample.lib lib /MACHINE:X86 /DEF:%ffmpeglibpath%\postproc-52.def /OUT:%ffmpeglibpath%\postproc.lib del %ffmpeglibpath%\*.exp @rem 这里设置x64文件目录 SET ffmpeglibpath=G:\ffmpeg-1.2\x64\lib lib /MACHINE:X64 /DEF:%ffmpeglibpath%\avcodec-54.def /OUT:%ffmpeglibpath%\avcodec.lib lib /MACHINE:X64 /DEF:%ffmpeglibpath%\avformat-54.def /OUT:%ffmpeglibpath%\avformat.lib lib /MACHINE:X64 /DEF:%ffmpeglibpath%\avutil-52.def /OUT:%ffmpeglibpath%\avutil.lib lib /MACHINE:X64 /DEF:%ffmpeglibpath%\avfilter-3.def /OUT:%ffmpeglibpath%\avfilter.lib lib /MACHINE:X64 /DEF:%ffmpeglibpath%\avdevice-54.def /OUT:%ffmpeglibpath%\avdevice.lib lib /MACHINE:X64 /DEF:%ffmpeglibpath%\swscale-2.def /OUT:%ffmpeglibpath%\swscale.lib lib /MACHINE:X64 /DEF:%ffmpeglibpath%\swresample-0.def /OUT:%ffmpeglibpath%\swresample.lib lib /MACHINE:X64 /DEF:%ffmpeglibpath%\postproc-52.def /OUT:%ffmpeglibpath%\postproc.lib del %ffmpeglibpath%\*.exp pause
将上面的文本复制为批处理,并修改lib文件目录路径,即可重新生成lib文件。