Visual Studio 2013 fatal error C1041 /FS

C++Compiler ErrorsVisual Studio-2013

C++ Problem Overview


I'm using Visual Studio 2013. Every so often by project refuses to compile. If I undo any changes, it still won't compile. I've found that recreating the entire project works. I would like to actually fix the problem though. The error that I'm getting is:

1>Critic.cpp : fatal error C1041: cannot open program database 'c:\users\username\desktop\projectName\projectName\x64\debug\vc120.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS

I've tried following these instructions to no avail: http://msdn.microsoft.com/en-us/library/dn502518.aspx

Has anyone else encountered this and found a fix?

C++ Solutions


Solution 1 - C++

I had this problem because different projects in a solution had the same intermediate directory.

Changing

$(Platform)\$(Configuration)\

to

$(Platform)\$(Configuration)\$(ProjectName)\

in

Configuration Properties | General | Intermediate Directory

in each of the projects solved it.

Solution 2 - C++

I agree with PThomasCS.

Firstly I tried to use Microsoft advice /FS (Force Synchronous PDB Writes):

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Working with Project Properties.
  2. Select the C/C++ folder.
  3. Select the Command Line property page.
  4. Modify the Additional Options property to include /FS and then choose OK.

but it didn't work.

I noticed that dropbox lock the file. I stopped the synchronization. After that error disappeared. So try to close/stop any program that may lock the files.

Hope this helps.

Solution 3 - C++

in the C/C++->General settings page for each project, setting the Multi_processor compilation option to No helped me.

Solution 4 - C++

if you use CUDA, then set

Project -> Properties -> CUDA C/C++ -> Host -> Additional Compiler Options -> /FS

Solution 5 - C++

I found the same problem compiling libkml on VS2013 (the error appears specifically at libkmlxsd project inside libkml solution).

Error	112	error C1041: cannot open program database 'd:\gstabel\falkermap2\libkml-1.2.0\msvc\debug\vc120.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS	d:\gstabel\falkermap2\libkml-1.2.0\src\stdafx.cpp	1	1	libkmlxsd

The /FS (Force Synchronous PDB Writes) flag work for me. But I had to set in all projects inside the solutions, and Rebuild all, to make it works.

Solution 6 - C++

I had a similar problem: c++ repos that would build fine for other people on my team would not build properly for me (gave .PDB /FS errors as mentioned in the question) and sometimes also link errors. Someone pointed out that I was cloning one of the repos to a location in my Dropbox. After trying many other ideas, I finally made a new clone to a non-dropbox location and the solution compiles without errors. I suspect that the issue could be common to other file synchronization services. (Box, Google drive etc), though I have not tested those.

Solution 7 - C++

I had this problem too and I solved it by deleting .pdb file from project directory and recompiling

Solution 8 - C++

As the error message hints, this error happens when multiple processes try to access the project's PDB file at the same time, which can happen if you enable parallel compilation (I had the problem with a third-party build scheduler, I'm not sure whether this can happen also when the build is managed by Visual Studio's own scheduler).

The instructions to use the /FS compiler option point you in the right direction, the trick is making sure that the compiler option is always used in your compilation.

If you're using CMake to generate the solution file, you should specify the /FS flag in the CMAKE_C_FLAGS and/or CMAKE_CXX_FLAGS (to see them you might need to tick the Advanced checkbox in the CMake GUI) and regenerate the solution.

If you're using CUDA, as Fillippo noted in his answer, you need to make sure the host compiler sets the flag as well. For a Visual Studio-generated solution, set the flag in the CUDA C/C++ -> Host -> Additional Compiler Options in the project properties page. For CMake-generated solution files, however, you won't have any CUDA C++ properties page, so you need to edit the CMake configuration instead. Just add the /FS flag to the CMAKE_{C,CXX}_FLAGS as mentioned above and check that CUDA_PROPAGATE_HOST_FLAGS is set to ON (which is its default value).

Solution 9 - C++

I had the same issue with vs2017 generated with cmake. I tried adding /FS to both CMAKE_C_FLAGS and CMAKE_CXX_FLAGS but it didn't help. I did not want to sacrifice multi-processor compilation because I have a fairly large project and I want my project built as fast as possible using all the cores available on my PC.

So instead, I opted to switch cmake's default debug flag /Zi to /Z7 which embeds the debug symbols into the .obj (similar to how GCC/Clang works) instead of creating an external .pdb. It worked for me.

    STRING(REGEX REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
    STRING(REGEX REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")

Please be aware that using /Z7 will make your binary significantly larger.

Solution 10 - C++

If you have multiple projects within the solution, you need to add /FS to each project for it to work. Simply select the project->properties->C/C++ -> Commandline ->Additional Options.

Solution 11 - C++

I was running a backup service. My problem was that the backup service kept backing up the new .pdb file from the previous compilation when the compiler tried to write out the .pdb file. By excluding .pdb files from backup I resolved this issue for good.

This type of problem is hard to track down because it is intermittent. After the backup is completed there is no longer a conflict when the compiler creates the new .pdb file, so you may think some other solutions worked.

Solution 12 - C++

The /FS tag need to be place in linker command Line. Work well

Solution 13 - C++

I had the same problem and the solution was very simple: the disk was full...

But the error message was not very helpful in this case... I found it by using process monitor.

Solution 14 - C++

same problem here too

  • /FS did not work
  • deleting VS2013 files did not work
  • restarting the computer did not work
  • removing the header and source files from the project and re-adding them, did not work
  • turning off google drive and dropbox did not work

I had to delete the corrupted copy and use my backup copy - usually everyday, I drop a copy of my working folder into a backup drive

Solution 15 - C++

What solved it for me was to manually kill the mspdbsrv process. Something in there occasionally doesn't handle concurrent builds well, and gets stuck in an erroneous state. The next build re-launched the pdb server and all went back to normal.

Solution 16 - C++

Delete the whole debug directory.

Solution 17 - C++

One of the reasons why this error may occur is that pdb files are marked with a read-only attribute. If they are, remove the read-only attribute from the file.

To remove Right Clik on PDB File -> Properties -> Uncheck Attributes: ReadOnly

Solution 18 - C++

I had this problem on several projects. On those projects I had <ProgramDataBaseFileName> set under the <ClCompile> section. Removing the <ProgramDataBaseFileName> section and its tag (so that Visual Studio uses the default) made this go away.

Solution 19 - C++

I had a similar issue. I couldn't even delete the pdb files of my project. Windows told me that the application serviceHub.Host.CLR.x64 accessed these files. This process is used by Visual Studio although Visual Studio was restarted.
Killing this process helped!

Solution 20 - C++

I faced the same problem.

Deleting complete $(IntDir) worked for me.

Solution 21 - C++

I had the same problem and the Intermediate directory was empty for that project. So the accepted fix did not work for me.

I fixed it by doing a clean and build on the project that gave the error

Solution 22 - C++

I ran into this issue while building in Qt Creator with MSVC. Creating the missing debug folder and rebuilding fixed the issue.

Solution 23 - C++

I was trying to build on a docker volume. It seems that cl.exe cannot handle mapped directories. I copied the files to a non-mapped folder and it compiled successfully.

Solution 24 - C++

Fixed by Sign out & Log In

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPThomasCSView Question on Stackoverflow
Solution 1 - C++testView Answer on Stackoverflow
Solution 2 - C++MaksView Answer on Stackoverflow
Solution 3 - C++Darren EvansView Answer on Stackoverflow
Solution 4 - C++FillippoView Answer on Stackoverflow
Solution 5 - C++Gabriel C. StabelView Answer on Stackoverflow
Solution 6 - C++user2373786View Answer on Stackoverflow
Solution 7 - C++Juraj MuráňView Answer on Stackoverflow
Solution 8 - C++GPhiloView Answer on Stackoverflow
Solution 9 - C++mchiassonView Answer on Stackoverflow
Solution 10 - C++VSnoobView Answer on Stackoverflow
Solution 11 - C++atlakeView Answer on Stackoverflow
Solution 12 - C++Sylvain PView Answer on Stackoverflow
Solution 13 - C++Sebastian JänickeView Answer on Stackoverflow
Solution 14 - C++forest.petersonView Answer on Stackoverflow
Solution 15 - C++Ofek ShilonView Answer on Stackoverflow
Solution 16 - C++skanderusaView Answer on Stackoverflow
Solution 17 - C++user2898339View Answer on Stackoverflow
Solution 18 - C++capsView Answer on Stackoverflow
Solution 19 - C++RaildexView Answer on Stackoverflow
Solution 20 - C++UrbanView Answer on Stackoverflow
Solution 21 - C++George ArokiamView Answer on Stackoverflow
Solution 22 - C++nyanpasu64View Answer on Stackoverflow
Solution 23 - C++Yusuf Tarık GünaydınView Answer on Stackoverflow
Solution 24 - C++aggelos garaleasView Answer on Stackoverflow