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:
Error 1 fatal error LNK131开发者_运维问答8: 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?
Turned out that I needed to delete all of the project temp files inc. caches etc., kill the debug symbol server and restart windows.
I've seen LNK1318: Unexpected PDB error; UNKNOWN (24) when linking.
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.
This one worked for me: Project properties -> C/C++ -> Code Generation -> Enable Function Level Linking -> Yes
I had the same problem when upgrading VS2019 v16.10.x to v16.11.x.
This fixed it for me:
Open your *.vcxproj file(s). Look for this line :
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Just below that, add these 3 lines :
<PropertyGroup>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
Now the 64-bit tool chain is used and you should no longer have any problems.
Best solution for me has always been to simply kill Visual Studio's Debug Symbol Server:
for /F "tokens=2 delims= " %I in ('tasklist|findstr /I "mspdbsrv.exe"') do taskkill /F /PID %I>NUL && echo VS Debug Symbol Server killed.
This command could also be run from a batch file like so:
@for /F "tokens=2 delims= " %%I in ('tasklist^|findstr /I "mspdbsrv.exe"') do taskkill /F /PID %%I>NUL && echo Debug Symbol Server killed.
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.
See if you can successfully build on release mode
Rebuilding the project solved the problem
If using /MP
or /MDd
with MSBuild, also use the /Zf
compiler option. (See https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1318 )
Other troubleshooting steps for LNK1318:
- Do a full Clean/Rebuild
- Restart mspdbsrv.exe
- Turn off antivirus checks in your project directories.
- Change the
Debug Information Format
to/C7
orNone
- Try building with
/property:_IsNativeEnvironment=true
I got the build error as follow also: LINK : fatal error LNK1318: Unexpected PDB error;
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.
http://connect.microsoft.com/VisualStudio/feedback/details/296978/link-fatal-error-lnk1318-unexpected-pdb-error-unknown-24
http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9e58b7d1-a47d-4a76-943a-4f35090616e8
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.
This worked for me: Go to Project properties -> C/C++ -> Code Generation ->Runtime Library->Multi-threaded Debug (/MTd).
this looks to be some incredibuild issue. refer: https://incredibuild.force.com/s/article/fatal-error-LNK1318-unexpected-PDB-error-OK-0
Fatal error LNK1318: Unexpected PDB error; OK (0) Content
--> This error may occur in a random manner - usually when building large Solutions.
There are 2 ways solving your LNK1318 error:
1. Switching to the old PDB method - C7 (/Z7) since this error seems to invoke when the regular "PDB for Edit And Continue" option is enabled.
2. Switching to 64-bit native compiler. You can enable the 64bit native compiler using Agent Settings -> Visual Studio Builds -> Advanced. Under the "PDB File Allocation" please mark the "Force 64-bit toolset".
精彩评论