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

Posted on 2000-01-08
Medium Priority
Last Modified: 2012-05-04
in linux does make complie both c and c++ files?
Question by:dvd99
LVL 51

Accepted Solution

ahoffmann earned 0 total points
ID: 2336068
make does not compile anything, but g++ may do both

Author Comment

ID: 2336594
what does make do?
LVL 51

Expert Comment

ID: 2336640
make - maintain program dependencies
(cannot give a better explanation than man make)
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.


Expert Comment

ID: 2346444
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!



Expert Comment

ID: 2365279
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.
LVL 51

Expert Comment

ID: 2367796
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)

Expert Comment

ID: 2367930
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)

LVL 51

Expert Comment

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

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question