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

in linux does make complie both c and c++ files?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

make does not compile anything, but g++ may do both

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dvd99Author Commented:
what does make do?
make - maintain program dependencies
(cannot give a better explanation than man make)
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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

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!


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.


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)

didier, don't worry, your comment helped to clarify things, anyhow ;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.