I am trying to understand what is the purpose of making files using commands such as cmake .. and make, I have tried looking online but there is no concise explanation on its purpose that i could find.

Also, is it necessary to use make on a project folder that is not built in order to use the source (C++) in other projects.

I know this may be a simplistic question, but as i am fairly new to building files, any information or references would be much appreciated.

3 Answers 3


If your program consists of a only a few files that can be built with a simple command line invoking the compiler, then make may be superfluous. However, in large projects you may have dozens of files that require complex compiler and linker options, then make or a similar tool becomes a necessity. Consider, if you have a project with 50 C++ source files, and you change just one of them, you don't want to have re-compile all of them. You'd much rather just re-compile the one file that changed and re-link with the existing object files for the rest of them. Tools like make automatically take care of chores like that.

The make language has a number of warts, and I don't think it is anybody's favorite programming language. It is also very tricky to write a makefile that will work on multiple platforms, say Linux, OS X, and Windows. Tools like cmake can be used to generate makefiles that will work on multiple platforms, and lets you describe the process of building your software in a language that is arguably less ugly than make proper.

  • make language is in fact one of my favorite languages.
    – aragaer
    Jun 10, 2014 at 20:42
  • 5
    Hmm. Well, de gustibus non est disputandum. I think you'll have to admit that you are in a minority on that. Jun 10, 2014 at 20:44
  • I was not even aware that it is a language of its own! very helpful , thankyou. Will upvote when i can.
    – foo
    Jun 10, 2014 at 20:48

make is sort of a batch process for compiling/linking/building, etc. You could do all of these steps manually, or you can just use make.

More info here: http://c.learncodethehardway.org/book/ex2.html and http://www.gnu.org/software/make/


Until your project is small, it is very easy to build it without any makefiles. But imagine your projects has 200 source files that you've divided in to a number of static and dynamic libraries, then passing the names of 200 files to the compiler in a command prompt would be impossible. Also you can create a batch file which builds your projects. But make files are superior to batch files. Particularly, when you use cmake your source code can be built with any compiler easily. That is why large projects use makefiles.

Note: If you use any convinient IDE like Visual Studio, you'll not often feel the need of writing makefiles, as the IDE makes it easy for you.

  • Elaborate answer thanks. Is it then possible to build the file directly from an IDE like Visual Studio?
    – foo
    Jun 11, 2014 at 6:58
  • No, you can't build a makefile using an IDE. But some large projects include projects files for such IDE. Open it and click the build option. In fact, some of the IDEs like CodeLite create a makefile automatically. In some of them you can turn on the feature.
    – Fish
    Jun 11, 2014 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.