I want to compile all the files in a given directory.
I don't want to use
gcc -o main file1.cpp file2.cpp file3.cpp ...
because there are many files.
So how do I compile all the files whose extension is .cpp in a given directory using terminal/bash?
You are asking for files with extension .cpp? So you can just type:
gcc -o main *.cpp
The shell expand the asterisk to file1.cpp, file2.cpp and so on of the current directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With