[Linux]

When using gcc and or g++ is there a way I can have two output files, one with and one without debugging symbols in one gcc/++ command? I don't want to have to write
g++ --Wall program.cpp -o program, then have to immediately run g++ --Wall -g program.cpp -o program2 in order to have both executables?

You have just reached the point where you are about to begin reinventing one of the standard tools of programmers; a Make tool. This, of course, is a good sign.

I advise you very strongly at this point to take nobody's recommendation, including mine. Make tools are something that nobody ever seems quite satisfied with, and as such it seems that there is an endless slow bubbling of new make tools, each one designed to solve a particular problem someone had (and, of course, in doing so that new tool suffers from some other problem that someone else won't like).

Make is the grandfather; Click Here. It has many variants, and in my opinion it remains something that everyone should have some understanding of (much as everyone should be able to read a little C), if only because it's so ubiquitous. The syntax is disconcerting and it shows its age, and there are various versions of it, but it's low-level enough that you should be able to understand every line in it and know exactly what it's doing for you. Some of the higher-level make tools have opaque abstractions which is fine, of course, but to begin with I believe it's important to understand what's going on.

Many other options are listed here: https://en.wikipedia.org/wiki/List_of_build_automation_software

As you can see, there are a lot of them. Make tools seem to be a classic attractor for pet projects.

The point is, there are standard tools in which you define what you're building, in what versions (e.g. debug build, release build) and you tell the make tool to build one. The make tool should keep track of the dependencies, recompile only what needs recompiling, and put the output files where you tell it to. In your case, you might have a debug binaries directory, and a release binaries directory. You might have a build with all the extra warnings turned on; you might have a build with the optimisations turned up all the way.

Anyway, the fact that you've now reached this point indicates clearly that you have a need for make tools. Take a look at them, pick something simple to start with, and see which one best fits your needs.

Edited 1 Year Ago by Moschops

Thanks Moschops that was helpful, although I think you vastly overestimate me. I hope one day to me actually using these tools and a regular, but for now I tinker and learn slowly and painfully.

Oh guy, there is so many switches and you need to hit right combo ...

This question has already been answered. Start a new discussion instead.