Reputation: 3
fatal error: can't create precompiled header stdc++.h.gch: Permission denied
I'm getting the above error while using the command g++ -std=c++14 stdc++.h
on windows powershell in the directory where stdc++.h is located. How do I fix this ?
Upvotes: 0
Views: 421
Reputation: 2495
There are two things to consider here.
The solution to the first one is easy. You are trying to make changes in a system directory. I assume the following attempt will succeed but I cannot test.
my_pch.hpp
that contains the following line in desktop or any other user directory.
#include <stdc++.h>
g++ -std=c++14 my_pch.hpp
You should get the same precompiled header.
You should ask yourself why you need a precompiled header. Answers on do we really need precompiled headers mentions about the effect of the size of the project, reduction in compile time, but facing with further problems. If you are unsure, it is advised not using them.
Upvotes: 1
Reputation: 914
Run Powershell as an administrator and it should work fine - you gain all permissions you need.
Upvotes: 0