r/C_Programming • u/Friendly_Couple_2312 • Aug 19 '26
automating gcc install and usage
Hi, Im a 2nd year cs student. Ive had problems with installing the gcc compiler and remembering its flags between coding sessions. I also helped many 1st year students with it and almost always its a little too complicated for them. For that i built gccauto. it auto install and saves flags for compiling. Im not a pro programmer so if you have any tips or ideas pls share them. (some ai was used to help build it since im still learning)
its called gccauto on github. ubay-mostafa/gccauto
0
Upvotes
7
u/rainboww_J Aug 19 '26
Nice! It's cool you found a problem you and other people around you had and made a tool to fix that. I can see this being useful for the small single file programs you make as a student. MSYS is a complex thing on its own if you're just starting out and have never used linux so automating that might make stuff much easier yes :)
Soon you'll find tho that programs will take up a lot
more than just a handfull of files and compiling them by hand in the command line will become cumbersome quite quickly. This is where build systems come into play. Some write a simple shell script with the same manual gcc calla, but lots of others will use a more complex build system like make or CMake.
Don't have time to look through the code itself but love the idea and the fact it has already helped others! Good luck with the rest of your studies and enjoy!
26
u/NotDG04 Aug 19 '26
Just use a makefile dude
3
u/mykesx Aug 19 '26
https://hub.docker.com/_/gcc
7
u/Interesting_Buy_3969 Aug 19 '26
That's a real problem and served as a reason for people to create automatic build systems, such as Makefile or CMake. You can also use a shell alias for that purpose, too, but it's not as flexible plus can't be configured per-project.
6
u/mrtlo Aug 19 '26
As already stated. This problem has been addressed endlessly... CMake is a popular solution. Thing is, writing C/C++ covers a lot of applications, and there is no "one size fits all". Understanding the compile/link cycle is a big part of systems programming...
16
u/von_rascher Aug 19 '26
tiktok kids era
3
u/ReallyEvilRob Aug 19 '26
If people can't figure out how to get gcc installed or how to use the correct flags, how are they going to figure out how to clone a repo?
1
u/GrandBIRDLizard Aug 19 '26
Make one ;)
1
u/Puzzled-Extent7817 Aug 19 '26 edited Aug 20 '26
linux you just make a function and throw it into your .bashrc
cdev() {
[[ $1 == *.c ]] || { echo "usage: cdev file.c" >&2; return 1; }
gcc -std=c23 -Wall -Wextra -pedantic-errors -g -fsanitize=address,undefined -o "${1%.c}" "$1" -lm
}
cppdev() {
[[ $1 == *.cpp ]] || { echo "usage: cppdev file.cpp" >&2; return 1; }
g++ -std=c++23 -Wall -Wextra -pedantic-errors -g -fsanitize=address,undefined -o "${1%.cpp}" "$1"
}