I switched to Ubuntu and I am having problem in precompiling bits/stc++.h header file as specified in a codeforces blog I did the same but at last step that is creation of precompiled header file in specified location it’s showing an error: fatal error: can’t create precompiled header stdc++.h.gch: Permission denied
The current working directory is /usr/include/x86_64-linux-gnu/c++/9/bits - Which is not needed. You can compile your C++ codes from the home directory itself.
You are trynna use the c++14 standard to compile - This is not needed for CP. You can use the g++ compiler to compile and run your code unless you are too specific about the compiler standard/version.
Open the terminal and navigate to the directory where your CPP scripts are present.
Use the following commands to compile
# Compile using g++ compiler
g++ script.cpp
# Execute the compiled script
./a.out
# Note that it will read the input from stdin
# so you have to type the input and hit enter so it reads it
# The output will be displayed on the terminal itself.
# Compile using g++ compiler but store the object file with a different name
g++ -o hello_world script.cpp
./hello_world
# or
g++ -o factorial prog1.cpp
./factorial
# Read input from a file and write output to another file
# Say input.txt has sample input and you
# want to write the output to output.txt
g++ -o factorial prog1.cpp
./factorial < input.txt > output.txt
If you are still confused and need help, you can post a comment.
All you have to do is put a “sudo” in front of the command.
Ex.
Your command :- g++ …(your compiling flags) stdc++.h
Ouput :- fatal error: can’t create precompiled header stdc++.h.gch: Permission denied