precompiled header in visual studio 2022

657 Views Asked by At

I am pretty new to creating a dll file, and I would like to use a precompiled header, so that I can build faster. I am currently using the Visual Studio 2022.

Here is my directory structure looks like

Foo
|-- include
|     |-- pch.h
|     |-- globalPch.h
|
|-- src
|     |-- pch.cpp
|     |-- globalPch.cpp
|     |-- dllmain.cpp
|     |-- FooDir
|     |     |-- A.cpp
|     |     |-- A.hpp
|     |     |-- B.cpp
|     |     |-- B.hpp

I have globalPch.h, which has all the standard library and some user typedef, and I have my pch.h to include all globalPch.h. So, I've set up the pch.cpp to create (/Yc) Precompile Header. Then, globalPch.cpp to Use(/Yu), and I realize that I actually put the relative path of pch.h into pch.cpp.

But I am getting an error saying that command-line option was not found in the source file on pch.cpp file. I right-clicked the pch.cpp --> Precompiled Headers --> Precompiled Header File --> set the path to pch.h. I still got the same error as above.

Is there a solution to this? or I looked at some OpenSource code if someone has a precompile header problem like me. But it looks like they've put pch.h and pch.cpp into the same dir. Is this conventional?

0

There are 0 best solutions below