Questions tagged [precompiled-headers]

A precompiled header is a header file that has statically compiled but still separate from its final executable in order to speed up compilation of dependent files.

In C and C++, precompiled headers allow for quicker compilation times by keeping the definitions from a given header in an compiled state. This allows the compiler to quickly incorporate the header when a file dependent on the header is being compiled.

Rather than having to parse through code, precompiled headers allow the compiler to skip directly to a more intermediate state. For headers that are used frequently this can result in significant compile-time savings.

454 questions
2
votes
1 answer

Visual studio fails to create precompiled header

For some reason visual studio does not want to cooperate and create the .pch file. I have the following structure: mysolution.sln myproject.sln source main.cpp stdafx.h stdafx.cpp (only includes stdafx.h) I have set my Project -> Properties…
Gregor Sattel
  • 352
  • 3
  • 12
2
votes
0 answers

Visual Studio 2019 - how to setup project with multiple precompiled headers

I'm having troubles setting up a project with multiple precompiled headers. As far as I read I can have as many as I want as long as there is only 1 per compile unit. Consider following example of targeted hierarchy: source precomp1.h …
Gregor Sattel
  • 352
  • 3
  • 12
2
votes
1 answer

Use cmake to conditionally generate source input files

I'm using cmake with C++ project. I want to use precompiled headers in GCC. I want to run cmake once and then, when running make, I want this actions to happen: Run my custom tool (python script) on whole source tree. It generates precompiled.h…
Max
  • 23
  • 1
  • 3
2
votes
0 answers

Trying to get Precompiled Headers running with Qt Creator on Mac

As soon as I add PRECOMPILED_HEADER = pch.h to my pro file, I get the fatal error 'debug/Example_Name_x86_64.pch/c_x86_64' file not found. I also have the lines CONFIG += precompile_header and HEADERS += pch.h in my pro file, is there anything I'm…
2
votes
2 answers

Why is my generated precompiled file so big when using a boost based library?

I'm working on a project using libraries handled through vcpkg. As compile time wasn't that great, I did some headers clean up and configured the project to use precompiled headers, putting STL and vcpkg headers inside. I started to run into the…
Runik
  • 155
  • 1
  • 9
2
votes
0 answers

Clang PCH performance worse than with headers?

I have a set of headers included to source files which is rarely/never changed. Parsing/reparsing of frequently changed source file which uses the headers (IDE use case) takes too long (few seconds). As a way to increase the performance i'd like to…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
2
votes
2 answers

Why the object is created also , When creating precompiled header?

I want to create a .pch within a make file. cl /nologo /c /YcPrecompiled.hpp /FpPrecompiled.pch Precompiled.cpp What confused me is : Why this command also create a object named Precompiled.obj Should I link this object to the finale exe? After…
bzhu
  • 908
  • 2
  • 9
  • 16
2
votes
2 answers

Bazel C++ precompiled headers implementation

I have written an MSVC Precompiled Header Files (PCH) implementation for Bazel (2.0) and would like to get some feedback on it as I'm not happy with it. To quickly recap what needs to be done to get PCH working in MSVC: Compile the PCH with /Yc and…
thfabian
  • 125
  • 9
2
votes
1 answer

Precompiled Header within C++ Project in VisualStudio not Linking correctly

Scenario If have the following directory structure within my VS Project. project/ | |-- include/ | | | pch.h | |-- src/ | | | pch.cpp | Project.cpp And my files read…
Justin Byrne
  • 179
  • 1
  • 2
  • 12
2
votes
1 answer

How to disable precompiled headers with msbuild?

The problem I have a VS2015 solution that uses precompiled headers. Our Continuous Integration server builds the solution using msbuild. We also use a coverage tool that has some issues with precompiled headers. The question How to tell to…
Cartucho
  • 3,257
  • 2
  • 30
  • 55
2
votes
0 answers

Failed to emit precompiled header (opencv, xcode)

My goal is to use opencv camera functions in react-native. Currently, I'm struggling to fix some errors. My project contains many files: When I try to build the project, I got two errors. For me the second error is most important: Failed to emit…
aromahyang
  • 21
  • 1
2
votes
0 answers

Deactivate precompiled headers by default Visual Studio C++

Every time I create a new project, I deactivate the pre-compiled headers in going in Properties -> C/C++ -> Precompiled Headers. Is there a way to configure Visual Studio to not have precompiled headers every time I create a project so I don't have…
Victor
  • 360
  • 3
  • 16
2
votes
1 answer

Move intermediate files of Visual Studio C++ build to another machine

We are looking for a way to speed up our local C++ builds. We have a simple idea in mind. We build our solution regularly on a build server. This build is incremental: when we push new changes, only necessary part of solution is rebuilt. Fast,…
Mikhail
  • 20,685
  • 7
  • 70
  • 146
2
votes
2 answers

changing from `stdafx.h` to `pch.h`

I clone a repo, c++ solution with 3 projects, a console application .exe a dll project .dll and a unit test .dll. I am not sure with what version of VS or compiler it was built or created. building the solution on my machine was throwing…
Amir-Mousavi
  • 4,273
  • 12
  • 70
  • 123
2
votes
1 answer

GCC, CMake, precompiled headers and maintaining dependencies

I'm trying to figure out how to maintain dependencies of my precompiled headers. It includes STL headers, some third-parties like boost and some of our rarely changing infrastructure headers. I came out with something like this SET(PCH_DIR…
kreuzerkrieg
  • 3,009
  • 3
  • 28
  • 59