Recently I've started to learn cpp language on linux,and now I run a cpp file using following commands.
g++ -o xxx xxx.cpp
./xxx
Is there a way to make it one line command such as compile-and-run xxx.cpp?Thanks.
|
Recently I've started to learn cpp language on linux,and now I run a cpp file using following commands.
Is there a way to make it one line command such as
| |||
|
feedback
|
|
Jeremy Banks has posted one of the most awesome tricks I've seen in quiet some time at SO. Basically, he's adding a single Bash-Script line at the top of the cpp file, which allows him to directly compile and execute that file. | |||||||||||
feedback
|
|
What about this? | |||||||||||
feedback
|
|
Create a Makefile like this:
Then just type | |||||
|
feedback
|
|
you can write a script. like:
then make it execupable | |||
|
feedback
|
|
a simple, generic makefile could do it:
will compile myprogram.c and will run myprogram. As it is defined with default rules, this works for every .c file in this directory. Naturally, you must care about libraries, include directories, and other dependencies ... I hope this helps, nevertheless | ||||
|
feedback
|