Precompiled headers with DLL solutions. Cannot open precompiled header file

*爱你&永不变心* 提交于 2019-12-21 04:08:42

问题


This worked without error when this solution worked off of .lib files instead of .dll files.

I have all of my projects except one currently using a precompiled header, without error. The precompiled header is called "LudoGlobal.h". I am trying to link the last project to this precompiled header (which exists in a seperate, "Core", project) but I'm getting the following error:

Error 4 fatal error C1083: Cannot open precompiled header file: '....\Output\LudoSound\Debug\LudoSound.pch': No such file or directory ludosoundmanager.cpp 1

for each .cpp file. Why is this? How can I solve it?

I realize LudoSound.pch does not exist. I am under the assumption that it probably gets created when LudoSound compiles, yesno?


回答1:


Are you using "automatically generate", or "use precompiled header" on the project and "create precompiled header" on the one cpp file? The latter is more efficient, but I've seen the per-file configuration on projects get accidentally reset, so that the "stdafx.cpp" (or whatever) file no longer generates the precompiled header.




回答2:


I had this issue after I deleted and re-added stdafx.cpp from & to my project. Solution:

  • stdafx.cpp needs to have the property Create PrecompiledHeader (/Yc), this sets stdafx.cpp as the one that is responsible for creating the .pch from stdafx.h
  • the project (and with that all the files in it) can have the property Use PrecompiledHeader (/Yu), they can use .pch created by the compilation of stdafx.cpp



回答3:


Try rebuilding your project in a new, copying only the files needed supplies.




回答4:


LudoSound.pch was not regenerated. Delete only the folder it was in and build again.



来源:https://stackoverflow.com/questions/1574121/precompiled-headers-with-dll-solutions-cannot-open-precompiled-header-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!