C++ Visual Studio 2013 致命错误 C1041 /FS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20643370/
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
Visual Studio 2013 fatal error C1041 /FS
提问by PThomasCS
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:
我正在使用 Visual Studio 2013。项目经常拒绝编译。如果我撤消任何更改,它仍然无法编译。我发现重新创建整个项目是有效的。不过,我想实际解决这个问题。我得到的错误是:
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
我试过按照这些说明无济于事:http: //msdn.microsoft.com/en-us/library/dn502518.aspx
Has anyone else encountered this and found a fix?
有没有其他人遇到过这个问题并找到了解决方法?
回答by test
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.
在每个项目中都解决了它。
回答by Maks
I agree with PThomasCS.
我同意PThomasCS。
Firstly I tried to use Microsoft advice /FS (Force Synchronous PDB Writes):
首先,我尝试使用 Microsoft 建议/FS(强制同步 PDB 写入):
To set this compiler option in the Visual Studio development environment
在 Visual Studio 开发环境中设置此编译器选项
- Open the project's Property Pages dialog box. For details, see Working with Project Properties.
- Select the C/C++ folder.
- Select the Command Line property page.
- Modify the Additional Options property to include /FS and then choose OK.
- 打开项目的属性页对话框。有关详细信息,请参阅使用项目属性。
- 选择 C/C++ 文件夹。
- 选择命令行属性页。
- 修改附加选项属性以包含 /FS,然后选择确定。
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.
希望这可以帮助。
回答by Darren Evans
in the C/C++->Generalsettings page for each project, setting the Multi_processor compilationoption to Nohelped me.
在每个项目的C/C++->Generalsettings 页面中,将Multi_processor 编译选项设置为No helpme。
回答by Gabriel C. Stabel
I found the same problem compiling libkmlon VS2013 (the error appears specifically at libkmlxsdproject inside libkmlsolution).
我发现在VS2013上编译libkml时遇到了同样的问题(该错误特别出现在libkml解决方案中的libkmlxsd项目中)。
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 projectsinside the solutions, and Rebuild all, to make it works.
该/ FS(强制同步PDB写入)对我旗的工作。但是我必须在解决方案中的所有项目中进行设置,并重新构建所有项目,以使其正常工作。
回答by user2373786
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.
我有一个类似的问题:对于我团队中的其他人来说可以正常构建的 C++ 存储库不会为我正确构建(给出了问题中提到的 .PDB /FS 错误),有时还会出现链接错误。有人指出我正在将其中一个存储库克隆到我的 Dropbox 中的某个位置。在尝试了许多其他想法之后,我终于对非 Dropbox 位置进行了新的克隆,并且该解决方案编译无误。我怀疑这个问题可能对其他文件同步服务很常见。(盒子,谷歌驱动器等),虽然我没有测试过这些。
回答by Fillippo
if you use CUDA, then set
如果您使用 CUDA,则设置
Project -> Properties -> CUDA C/C++ -> Host -> Additional Compiler Options -> /FS
项目 -> 属性 -> CUDA C/C++ -> 主机 -> 附加编译器选项 -> /FS
回答by Juraj Muráň
I had this problem too and I solved it by deleting .pdb file from project directory and recompiling
我也有这个问题,我通过从项目目录中删除 .pdb 文件并重新编译来解决它
回答by atlake
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.
我正在运行备份服务。我的问题是,当编译器尝试写出 .pdb 文件时,备份服务一直在备份来自先前编译的新 .pdb 文件。通过从备份中排除 .pdb 文件,我彻底解决了这个问题。
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.
这种类型的问题很难追踪,因为它是间歇性的。备份完成后,编译器创建新的 .pdb 文件时不再有冲突,因此您可能认为其他一些解决方案有效。
回答by Sylvain P
The /FS tag need to be place in linker command Line. Work well
/FS 标签需要放在链接器命令行中。干得好
回答by GPhilo
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).
正如错误消息所暗示的那样,当多个进程尝试同时访问项目的 PDB 文件时会发生此错误,如果启用并行编译就会发生这种情况(我遇到了第三方构建调度程序的问题,我不确定当构建由 Visual Studio 自己的调度程序管理时是否也会发生这种情况)。
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.
使用 /FS 编译器选项的说明为您指明了正确的方向,诀窍是确保编译器选项始终在您的编译中使用。
If you're using CMaketo 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 Advancedcheckbox in the CMake GUI) and regenerate the solution.
如果您使用CMake生成解决方案文件,您应该在CMAKE_C_FLAGS
和/或中指定 /FS 标志CMAKE_CXX_FLAGS
(要查看它们,您可能需要勾选CMake GUI 中的高级复选框)并重新生成解决方案。
If you're using CUDA, as Fillipponoted 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).
如果您使用 CUDA,正如Fillippo在他的回答中指出的那样,您需要确保主机编译器也设置了标志。对于 Visual Studio 生成的解决方案,请在项目属性页面的 CUDA C/C++ -> Host -> Additional Compiler Options 中设置标志。但是,对于 CMake 生成的解决方案文件,您将没有任何 CUDA C++ 属性页面,因此您需要改为编辑 CMake 配置。只需将 /FS 标志添加到CMAKE_{C,CXX}_FLAGS
上面提到的并检查CUDA_PROPAGATE_HOST_FLAGS
设置为 ON (这是其默认值)。