premake / premake/premake-core
One or more PCH files were found, but they were invalid
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 654
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 13
Description
I've been having some troubles getting my precompiled headers to work with premake5.
I've read the premake docs about precompiled headers and both docs about pchheader and pchsource and how they function. But I still keep getting this error.
==== Building framework (debug_x64) ====
Creating bin/x64/Debug
Creating obj/x64/Debug
stdafx.h
CameraComponent.cpp
cc1plus: error: one or more PCH files were found, but they were invalid
cc1plus: error: use -Winvalid-pch for more information
cc1plus: fatal error: obj/x64/Debug/stdafx.h: No such file or directory
compilation terminated.
framework.make:142: recipe for target 'obj/x64/Debug/CameraComponent.o' failed
make[1]: *** [obj/x64/Debug/CameraComponent.o] Error 1
Makefile:28: recipe for target 'framework' failed
make: *** [framework] Error 2
Below you can find the code. In the code I've got some project settings in a seperate lua file. such as names for the solution etc. The pch header works as intended on windows btw.
-- Solution configuration
local settings = require "project_settings"
local solution_name = settings.solution_name or "SDL2_Template"
local project_name = settings.project_name or solution_name
workspace(solution_name)
configurations{
"Debug",
"Release"
}
platforms{
"x64"
}
language "C++"
basedir(proj_dir)
location("build")
local proj_dir = settings.project_dir
project(project_name)
kind "ConsoleApp"
local p = path.getabsolute(path.join(proj_dir,"bin"))
print("Debug dir is " .. p)
includedirs{
path.join(proj_dir,"include"),
path.join(proj_dir,"3rdparty/include"),
path.join(proj_dir,"src")
}
files{
path.join(proj_dir,"src/**.cpp"),
path.join(proj_dir,"src/**.h"),
}
removefiles { "**/backup/**"}
filter "action:gmake"
pchheader("stdafx.h")
pchsource("src/stdafx.cpp")
filter "action:vs*" -- for Visual Studio actions
pchheader "stdafx.h"
pchsource(path.join(proj_dir,"src/stdafx.cpp"))
vpaths{ ["*"] = "src"}
-- general properties
filter "configurations:Debug"
symbols "on"
filter "configurations:Release"
flags{ "OptimizeSpeed","No64BitChecks"}
filter "system:windows"
local dll_hell = path.join(proj_dir, "AdditionalLibs")
local exe_hell = path.join(proj_dir,"bin")
print("Set build command to copy from ".. dll_hell .. " to " .. exe_hell)
prebuildcommands("JBT.py " .. path.join(proj_dir,"src"))
postbuildcommands{'xcopy \"'.. dll_hell .. '\" \"' .. exe_hell .. "\" /Y"}
local s = settings.win64_settings()
defines{"WINDOWS"}
links(s.links)
includedirs(s.includedirs)
libdirs(s.libdirs)
filter "system:linux"
local s = settings.linux64_settings()
links(s.links)
includedirs(s.includedirs)
libdirs(s.libdirs)
buildoptions{
"-x c++","-std=c++11","`sdl2-config --cflags --libs`"
}
sysincludedirs { "/usr/local/include/","/usr/include/" }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the gmake build using the shown pchheader("stdafx.h") and pchsource("src/stdafx.cpp") settings, then inspect the generated framework.make rule around the failing CameraComponent.o target. Compare the generated PCH path with src/stdafx.cpp and stdafx.h; done means the PCH is generated validly and CameraComponent.cpp compiles on Linux.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100