Link to home
Start Free TrialLog in
Avatar of dvd99
dvd99

asked on

in linux does make complie both c and c++ files?

in linux does make complie both c and c++ files?
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dvd99
dvd99

ASKER

what does make do?
make - maintain program dependencies
(cannot give a better explanation than man make)
make searches through a file defaultly named "Makefile" which contains instructions on how to correctly build a program.

  For instance:
main.cpp requires one.cpp

at the prompt you would normally do something like this.

Generate an object file for one.cpp
g++ one.cpp -c -o one.o

Generate an object file for main.cpp
g++ main.cpp -c -o main.o

Generate a binary that can be run
g++ main.o one.o -o progName

These steps could be explained in a Makefile so in the future all you need to type is

make
and off it goes.  It saves a great deal of time when you are building and debugging large programs.  

Get a good book on Linux Programming.  There are about three out there and the one I have gives a good introduction to it.

Linux Application Development isn't bad but there are others that go into further detail on make and configure which I think you will find interesting.


Enjoy your linux box!

Leimy

Just a slight correction.

Make doesn't maintain dependencies, it merely enforces them.

A makefile would typically contain a lost of objects your
program needs, how to produce those objects from source
files and what those source files depend on.

By following this information make can save you time by
building your program only if the source files or the files
they depend on have changed.

Again typically if make is succesfull and nothing changes
then a second call to make should do nothing.

-D

ps: For dependencies generation, look into makedepend which is part of XFree or the -M option of the gnu compiler.
didier, I just posted the head of the man page ;-)
BTW, make has nothing to do with compilers, especially not with makedepend, also source and objects files are too close to compilers, which is just one work to do for make
make is a general purpose utility (even for 5 pts)
You're right that's what the man page say.

I guess maintain to me sounds more like it actually updates
the dependency info... which it doesn't.

And you're right again it has nothing to do with compilers but
I was just going with the most common use.

I only mentionned makedepend since that is one tool that
does produce dependencies rather than just enforce them.

Anyway, I guess I didn't do a good job at explaining my point.

Sorry :O)

-D
didier, don't worry, your comment helped to clarify things, anyhow ;-)