What is the difference between make and g++?

Red Squirrel

No Lifer
May 24, 2003
70,056
13,514
126
www.anyf.ca
I know make uses some kind of special file with instructions on how to compile, but how does it differ from just using g++ directly and why is it used? I am trying to figure out an issue with serial communication and using the source of picocom to reference as picocom works fine to talk to the device but the minute I try talking to it with my own code or using echo / cat in the command line, all hell breaks loose and it starts spamming a bunch of bullcrap.

I'm starting to wonder if the way picocom is compiled may actually be having an effect on the behavior of the app. If I try to compile it with g++ it does not work, says a bunch of functions don't exist. I wanted to compare.

So what does make do differently than g++?

Also what is the difference between gcc and g++? I always use g++, should I be using gcc instead?
 

TheRyuu

Diamond Member
Dec 3, 2005
5,479
14
81
I know make uses some kind of special file with instructions on how to compile, but how does it differ from just using g++ directly and why is it used?

If all the command line options are the same there's no difference, just that typing "make" will be easier than going through every single source file. Also make can provide different targets to do different things (e.g. "make clean" to clean a directory structure of all object files). It makes dealing with any number of source files easy because basically you're specifying everything once (your source files relative to the make file, cflags, compiler, etc...) and just loop through the source files ("foreach") with linking at the end of it all.

Depending on the size/scope of the program the make file can be generated by a configure script (typically autoconf is used). I'm no expert on *nix build systems so take what I say here with a grain of salt. Google should be able to answer most basic questions about this stuff.

If I try to compile it with g++ it does not work, says a bunch of functions don't exist. I wanted to compare.

g++ is for compiling c++ source files so depending on what your source file is it may be treating the syntax differently from what you want it to, see below.

Also what is the difference between gcc and g++? I always use g++, should I be using gcc instead?

gcc and g++ are just frontends to various other tools provided by the gnu compiler suite (and binutils) and are basically the same thing (with different default options), one is meant for compiling c source files while the other c++ source files (guess which one does which :p).

The one you use will depend on your source code.
 

Chris27

Member
Sep 19, 2005
140
0
0
make is a utility to build programs, g++ is a C++ compiler (gcc is a C compiler). As a program grows in complexity, it becomes unfeasible to compile/build it without the aid of a build utility.
 

Red Squirrel

No Lifer
May 24, 2003
70,056
13,514
126
www.anyf.ca
Ohh I see. Guess I should probably learn make sometime and start using that. I usually just make a "rebuild.sh" file that runs g++. mysql++ programs can have really complicated compile strings. So guess make would make this easier to manage.