无法定位 xxxx 与动态链接库 avcodec-xx.dll上

http://blog.csdn.net/liuruihan/article/details/26716271

http://blog.csdn.net/bing87496988/article/details/25061659

http://blog.csdn.net/mythma/article/details/26558619


最近用vs2008在做一个基于ffmpeg的解码模块,debug下调试没有发现问题, 但是在release下运行时提示如下错误,百思不得其解,查了一下午也没找到什么问题。期间也换过不同的ffmpeg库,保证lib和dll是同一版本,但是也没有解决问题。

 

最终找到了问题的解决办法: release 项目属性中-----》连接器----》优化   选项中选择:保留未引用数据 



/////////////////////////////////////////////////////////////////////////////////////////////////////////////



win7 下开发视频服务器,用到ffmpeg,debug版本运行正常,切换到release时,出现"0x00905a4d 处未处理的异常: 0xC0000005: 读取位置 0x00905a4d 时发生访问冲突",原以为是jrtplib得问题,鼓捣半天才发现是ffmpeg. 用一个很小的测试程序验证,在av_register_all处就崩溃.鸟!
难道是用mingw生成ffmpeg时有调试信息,应用程序用release编译冲突?
ffmpeg版本老旧,有这个bug?
我编译的选项不对?
测试排除了上面3个疑问. 那就只有debug和release版本的区别了. 将release的优化选项逐个的剔除测试,找到了问题所在:
连接器->优化->引用 

在release版本下面使用"保留未引用数据(/OPT:NOREF)"选项才可以正常运行.

google "ffmpeg OPT:NOREF" 发现有人已经发现并解决了这个问题.

////////////////////////////////////////////////////////////////////////////////////////////

编译FFmpeg是一件痛苦的事情,一般都直接使用Zeranoe FFmpeg Builds

如果使用这个版本,需要注意ffmpeg的帮助里的一段话:

  1. To create import libraries that work with the /OPT:REF option (which is enabled by default in Release mode), follow these steps:  
  2.   
  3. Open the Visual Studio Command Prompt.  
  4. Alternatively, in a normal command line prompt, call ‘vcvars32.bat’ which sets up the environment variables for the Visual C++ tools (the standard location for this file is something like ‘C:Program Files (x86_Microsoft Visual Studio 10.0VCinvcvars32.bat’).  
  5.   
  6. Enter the ‘bin’ directory where the created LIB and DLL files are stored.  
  7. Generate new import libraries with lib.exe:  
  8.       
  9. lib /machine:i386 /def:..libfoo-version.def  /out:foo.lib  
  10. Replace foo-version and foo with the respective library names. 
即根据dll重新生成lib文件。

否则Relesae下就会出问题。


这是VS2010的一个bug,据说VS2012后已经修复。




原文地址:https://www.cnblogs.com/silyvin/p/9106868.html