LibVLC+Qt调用libvlc_new在Debug下正确运行Release下崩溃(VS2008)

在使用LibVLC+Qt包装食品播放器时遇到一个匪夷所思的问题,Debug下运行的很好,Release下初始化VLC便崩溃。

终于在Stack Overflow找到了问题的解决方案。

问题内容摘录如下:

问题:  fixing libvlc release mode crash with VC2010

描述:  I am using libVLC in one of my apps which I am compiling with VC2010 (also tried VC2008), the debug mode of my app works great but as soon as I compile to release mode and try to call into libVLC I get a crash. I asked for help on the vlc forums and someone mentioned this usually points to calling convention differences, however I am not sure what to check to see if this is the case or more importantly how to fix it.

some notes:

I am compiling libVLC using Ubuntu and following the how to guides on the libVLC wiki.
I'm using libVLC inside a C++ file.
I've tried compiling libVLC with and without debugging information.
I've tried calling libvlc_get_version and libvlc_new as my first call, both crash.
Even though I do not have symbols in my release version, I can see the call stack and it is definitely getting messed up as it is showing functions in the stack that are never-ever called which seems to indicate the wrong calling convention but again I'm not sure how to check/fix this.

I'm not sure if it is related but another issue I am having with libvlc is that I am trying to delay load the dll (have tried not doing this for the above problem but it didnt make a difference), i'm adding the linker flags: /DELAYLOAD:libvlc.dll /DELAYLOAD:libvlccore.dll , but when the linking occurs I get these warnings:

LINK : warning LNK4199: /DELAYLOAD:libvlc.dll ignored; no imports found from libvlc.dll
LINK : warning LNK4199: /DELAYLOAD:libvlccore.dll ignored; no imports found from libvlccore.dll
However it is definitely linking to the lib and requiring the dll as seen with Dependency Walker (not to mention I am calling into it).. again not sure if this is related but wanted to throw it out there as well.

I appreciate any advice/help on this one. Thanks!

解决办法一:

adding /INCREMENTAL to linker flags

解决办法二:

set Linker\Optimization\References to No (/OPT:NOREF)

一个比较好的问题解释:

I just came to the same problem and after some digging up with IDA dissasembler I've found out that linker throws out all libvlc imports. And yes INCREMENTAL flags adds them back in but as you said it's not the explanation of the problem.

Now I had a similar occurrence when designing a driver where Release eliminated function pointers and strings. And the solution was to set Linker\Optimization\References to No (/OPT:NOREF). So then linker leaves in all references even if it thinks they are not used.

And of course that fixes the problem.

So another mystery solved.

Best regards Waldemar

我用方法二顺利解决了问题。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值