我在一个使用 VC2010 编译的应用程序中使用 libVLC(也尝试过 VC2008),我的应用程序的调试模式工作得很好,但是一旦我编译到发布模式并尝试调用 libVLC,我就会崩溃。我在 vlc 论坛上寻求帮助,有人提到这通常指向调用约定差异,但是我不确定要检查什么来查看是否是这种情况,或更重要的是如何修复它。
一些注释:
- 我正在使用 Ubuntu 编译 libVLC,并遵循 libVLC wiki 上的操作指南。
- 我在 C++ 文件中使用 libVLC。
- 我尝试过使用和不使用调试信息来编译 libVLC。
- 我尝试将 libvlc_get_version 和 libvlc_new 作为我的第一次调用,但都崩溃了。
尽管我的发行版本中没有符号,但我可以看到调用堆栈,它肯定会变得混乱,因为它显示堆栈中从未被调用过的函数,这似乎表明了错误的调用约定,但我再次不知道如何检查/修复这个问题。
我不确定它是否相关,但我在 libvlc 方面遇到的另一个问题是我试图延迟加载 dll(已尝试针对上述问题不这样做,但没有什么区别),我添加了链接器标志:/DELAYLOAD:libvlc.dll /DELAYLOAD:libvlccore.dll
,但是当链接发生时,我收到这些警告:
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
然而,它肯定链接到 lib 并需要 dll,如 Dependency Walker 所示(更不用说我正在调用它)..再次不确定这是否相关,但想要把它也扔出去。
我很感谢对此的任何建议/帮助。谢谢!
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!
发布评论
评论(2)
我刚刚遇到了同样的问题,在使用 IDA 反汇编器进行一些挖掘后,我发现链接器抛出了所有 libvlc 导入。是的,增量标志将它们添加回来,但正如您所说,这不是问题的解释。
现在,我在设计驱动程序时遇到了类似的情况,其中 Release 消除了函数指针和字符串。解决方案是将 Linker\Optimization\References 设置为 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
实际上,添加“/OPT:NOREF”也可以解决问题,至少就我而言是这样。我认为这个问题可能是由于 dlltool 的“问题”造成的,因为 ffmpeg 也遇到了同样的问题(http://ffmpeg.org/platform.html#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b),并且像 ffmpeg 一样,libvlc(我猜)可能会生成 windows ' lib' 文件带有 'dlltool' 而不是 msvc 中的 'lib.exe'。与 dlltool 相关的错误报告位于:https://sourceware.org/bugzilla/ show_bug.cgi?id=12633#c1
由于您声称您正在“使用 Ubuntu 编译 libVLC”,我认为您可能遇到了同样的问题。希望有帮助。
顺便说一句,ffmpeg 的官方发行版提供了“.def”文件,因此我可以使用 msvc 中的“lib.exe”重新生成“正确”的 lib 文件并解决问题。然而,由于vlc的官方windows发行版不提供“.def”文件,并且我无法通过“dumpbin和lib”方法重建lib文件(dumpbin时失败,dll一定有什么奇怪的地方),我无法做进一步验证。
Actually, adding '/OPT:NOREF' solves the problem as well, at least in my case. and i think the problem may result from an 'issue' with dlltool, as ffmpeg suffers the same problem (http://ffmpeg.org/platform.html#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b), and like ffmpeg, libvlc(i guess) may generate windows 'lib' files with 'dlltool' instead of 'lib.exe' from msvc. the related bug report with dlltool is here: https://sourceware.org/bugzilla/show_bug.cgi?id=12633#c1
as you claimed that you were "compiling libVLC using Ubuntu", i think you probably encountered the same problem. hope it'll help.
btw, the official distribution of ffmpeg provide '.def' files, so i could regenerate the 'correct' lib files with 'lib.exe' from msvc and problem solves. however, as the official windows distribution of vlc does not provide '.def' files, and i failed to reconstruct the lib files via the 'dumpbin and lib' approach(failed when dumpbin, there must be something strange with the dll), i cannot do further verification.