visual-studio LNK1318:意外的 PDB 错误;好的 (0)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4256524/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
LNK1318: Unexpected PDB error; OK (0)
提问by chillitom
I'm trying to link against a library (libcef_wrapper_dll.lib) that was built with the /MDd flag. My application is build with /MDd and /CLR so should be compatible. The project compiles fine but when linking I get the very unhelpful error below:
我正在尝试链接一个使用 /MDd 标志构建的库 (libcef_wrapper_dll.lib)。我的应用程序是用 /MDd 和 /CLR 构建的,所以应该是兼容的。该项目编译正常,但在链接时出现以下非常无用的错误:
Error 1 fatal error LNK1318: Unexpected PDB error; OK (0) '' c:\Projects\Cef\CefSharp\libcef_dll_wrapper.lib 1 CefSharp
I don't have a .PDB file for the .LIB, do I need one?
我没有 .LIB 的 .PDB 文件,我需要一个吗?
采纳答案by chillitom
Turned out that I needed to delete all of the project temp files inc. caches etc., kill the debug symbol server and restart windows.
原来我需要删除所有的项目临时文件。缓存等,杀死调试符号服务器并重新启动Windows。
回答by doctorlove
I've seen LNK1318: Unexpected PDB error; UNKNOWN (24) when linking.
我见过 LNK1318:意外的 PDB 错误;链接时未知 (24)。
It happened when I had more than two links of large outputs happening at once - mspdbsrc.exe used more and more memory, hit 2gig or so, then crashed.
它发生在我同时发生两个以上的大输出链接时 - mspdbsrc.exe 使用了越来越多的内存,达到 2gig 左右,然后崩溃。
回答by mk_
This one worked for me: Project properties -> C/C++ -> Code Generation -> Enable Function Level Linking -> Yes
这个对我有用:项目属性 -> C/C++ -> 代码生成 -> 启用函数级链接 -> 是
回答by Abhijith Karkal
Rebuilding the project solved the problem
重建项目解决了问题
回答by Andreas
Best solution for me has always been to simply kill the symbol server. I have a batch file on my desktop to do this:
对我来说最好的解决方案一直是简单地杀死符号服务器。我的桌面上有一个批处理文件来执行此操作:
@for /F "tokens=2 delims= " %%I in ('tasklist^|findstr /I "mspdbsrv.exe"') do taskkill /F /PID %%I>NUL && echo Process killed.
回答by cowlinator
If using /MPor /MDdwith MSBuild, also use the /Zfcompiler option. (See https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1318)
如果使用/MP或/MDd与 MSBuild 一起使用,还请使用/Zf编译器选项。(参见 https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1318)
Other troubleshooting steps for LNK1318:
LNK1318 的其他故障排除步骤:
- Do a full Clean/Rebuild
- Restart mspdbsrv.exe
- Turn off antivirus checks in your project directories.
- Change the
Debug Information Formatto/C7orNone - Try building with
/property:_IsNativeEnvironment=true
- 做一个完整的清理/重建
- 重启 mspdbsrv.exe
- 关闭项目目录中的防病毒检查。
- 更改
Debug Information Format为/C7或None - 尝试构建
/property:_IsNativeEnvironment=true
回答by DragonDU
I got the build error as follow also: LINK : fatal error LNK1318: Unexpected PDB error;
我也收到了构建错误,如下所示:链接:致命错误 LNK1318:意外的 PDB 错误;
There are severa URL talked about this, but it seeems no completed solutions. Someone said mspdbsrv.exe is the trouble maker. After I clean the incremental build result and make a real clean build, it works well.
有几个 URL 谈到了这个,但似乎没有完整的解决方案。有人说 mspdbsrv.exe 是麻烦制造者。在我清理增量构建结果并进行真正干净的构建后,它运行良好。
http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9e58b7d1-a47d-4a76-943a-4f35090616e8
http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9e58b7d1-a47d-4a76-943a-4f35090616e8
回答by Sid Sarasvati
This is a technical limitation of the VC linker. You should try split your code modules up more. Splitting up libraries also help with extremely long link times.
这是 VC 链接器的技术限制。您应该尝试更多地拆分代码模块。拆分库也有助于极长的链接时间。
See if you can successfully build on release mode
看看你是否可以在发布模式上成功构建
回答by DanW
I had the problem because I had a file with the /clr option that was messing things up. I moved the CLR specific code to a separate file, cleaned, rebuilt and the problem is gone.
我遇到了这个问题,因为我有一个带有 /clr 选项的文件,它把事情搞砸了。我将 CLR 特定代码移到了一个单独的文件中,经过清理、重建,问题就消失了。

