I'm reading up on makefiles for my C++ program, and from this article http://myweb.stedwards.edu/laurab/help/makefilehelp.htmlMy understanding is that:

-o somefile :

specifies that any files after somefile will be outputted to somefile

-c somefile :

stops somefile from linking/compiling unless it is updated and ran

although I'm not sure because the manual: http://linux.die.net/man/1/g++ simply states that -c will stop the linker from running.

-g somefile:

spits out debugging information

Also, I found no information regarding -f from the manual, and explanations on what they do were scarce in all the makefile tutorials I read. I'm guessing this might be basic info, but I can't find what they do in the manual..

Also, is there a command for g++ in command prompt that allows me to look up the uses of commands like these?

Ex HELP "-f" except that doesn't work...

2

Best Answer


-o file

This will simply specify the output file name. By default, I think it is a.out

-c

When calling g++ with -c, it will only compile, without performing the link operation.This is very useful in big project, so you can compile file by file and link afterward. This way, you do not have to recompile the whole project when you edit just one file.

-g N

-g will specify the level of debugging symbols you want to add. g++ can add a lot of symbols when compiling that can be read later on by debuggers like gdb. Usually, when you develop, you compile with -g 3. Be careful to remove it for the release. It makes the binary much bigger and slower.Depending on this, you will have more or less information within gdb.

-f

Within g++, -f is not a flag by itself, it just a prefix. However, in your example, -f is not sent to g++ but to make. As said in the previous anwser, -f for make specify which Makefile to use.

The -f flag in make is defined as follows,

make -f makefile Specifies a different makefile. The argument makefile is a pathname of a description file, which is also referred to as the makefile. A pathname of '-' shall denote the standard input. There can be multiple instances of this option, and they shall be processed in the order specified. The effect of specifying the same option-argument more than once is unspecified.