re: long "g++ command"...
Make a C/C++ program to do it for you
Something like...
clink.c
#include <stdlib.h>
#include <stdio.h>
void usage();
int main(int argc, char *argv[])
{
char *flags = "-W -Wall -s -pedantic-errors";
char compilecommand[150]="\0";
if (argc != 3) usage();
else
{
snprintf(compilecommand, 149, "g++ %s %s -o %s", flags, argv[1], argv[2]);
system(compilecommand);
}
return 0;
}
void usage()
{
fprintf(stderr, "Usage: ./clink [source file] [desired name of executable]\n");
fprintf(stderr, "Example: ./clink testprog.c testworked\n");
fprintf(stderr, "Warning: If the combined lengths of the source file and executable are too long,
compilation and linking will not be successful\n");
}
Where I am (today), I don't have easy access to a C compiler or the time to access one. So, that code might have bugs (I wrote it in 90 seconds, and I didn't test it)! If so, treat it as a debugging exercise, but I hope it's bug free and makes your life easier.
Of course, writing a makefile would ordinarily make more sense, but this is a good way to practice C.
Edit: To compile clink.c, try something like
gcc -ansi -pedantic -Wall clink.c -o clink
To give yourself permission to execute clink,
chmod u+x clink
Also, you're lucky to be learning C++ and not Java as a first language!