How to Precompiled Header Setup in Ubuntu for Sublime Text help me!

Revision en1, by ahnaf09, 2025-10-11 16:09:39

I am new to Ubuntu and trying to precompile the bits header for faster C++ compilation. On my system, the path to the header files is:

/usr/include/x86_64-linux-gnu/c++/11/bits

Listing the directory contents after navigating to the path shows the following: Directory Listing


Current Sublime Text Build System

Here is my current Sublime Text build configuration:

{
  "shell_cmd": "g++ -std=c++20 -O2 -Wall -Wextra -Wshadow -Wconversion -Wfloat-equal -Wno-unused-result -DLOCAL -include ~/.stdc++.pch -o '$$${file_path}/$$${file_base_name}' '$$${file}' && timeout 10s '$$${file_path}/$$${file_base_name}'  \lt  '$$${file_path}/in.txt' > '$$${file_path}/out.txt' 2 \gt  '$$${file_path}/err.txt'",
  "file_regex": "^(...*?):([0-9]+):([0-9]+): (.*)$",
  "working_dir": "${file_path}",
  "selector": "source.c++, source.cpp",
  "variants": [
    {
      "name": "Run Only",
      "shell_cmd": "timeout 10s '$$${file_path}/$$${file_base_name}' < '$$${file_path}/in.txt'  \gt  '$$${file_path}/out.txt' 2> '${file_path}/err.txt'"
    },
    {
      "name": "Compile Only",
      "shell_cmd": "g++ -std=c++20 -O2 -Wall -Wextra -Wshadow -Wconversion -Wfloat-equal -Wno-unused-result -DLOCAL -include ~/.stdc++.pch -o '$$${file_path}/$$${file_base_name}' '${file}'"
    }
  ]
}

Errors Encountered

After using this build system, I received compilation errors as shown in the screenshot: Compilation Error


Notes

  • The build attempts to include a precompiled header ~/.stdc++.pch.
  • Compilation fails, possibly due to incorrect precompiled header setup or incompatible paths.
  • I am looking for a proper way to precompile the bits header in Ubuntu and integrate it with Sublime Text.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ahnaf09 2025-10-11 16:13:12 61
en1 English ahnaf09 2025-10-11 16:09:39 1920 Initial revision (published)