I work in c++ mostly as a hobby (I'm still in school and therefor don't have a real job). The IDEs generate the makefile for me and so I'm wondering if it's worth learning how to make them myself. By "worth learning" I mean, should I drop everything and learn how to write them before continuing to learn c++? Is learning them going to be really necessary? If so, should I learn about them (general syntax and understanding how they work etc.) or really learn how to write them?

  • 1
    most open-source projects make heavy use of makefiles in one way or another. So, yes, you should learn how makefiles work. Writing them by hands is another story and should be avoided in preference to generating them by some tool except you have very few files or can use generic/implicit rules and other similar techniques
    – permeakra
    Aug 26, 2012 at 9:51
  • if you want to have others compile your source on Linux and other Unix-based operating system, you need to learn them.
    – user1249
    Aug 26, 2012 at 21:45
  • You could learn the basics of makefiles, dependencies and substitutions etc, in less time that it will take you to read all the answers to this question :)
    – JohnB
    Dec 23, 2012 at 11:42

8 Answers 8


Yes, it is definitely worth understanding how Makefiles work. It might not be relevant to you right now (because you are using an IDE that generates them), but the chances are that the knowledge will be useful in the future.

By "worth learning" I mean, should I drop everything and learn how to write them before continuing to learn c++?

Frankly, that is a bizarre notion of "worth learning" ...

But no I don't think you need to do that.

Is learning them going to be really necessary?

We cannot predict whether you are really going to need this knowledge in the future. It depends on whether you continue with C++ programming and what context you do it in.

If so, should I learn about them (general syntax and understanding how they work etc.) or really learn how to write them?

I'd recommend both. If you can't write a Makefile, it is debatable that you know what is going on.

There is the other viewpoint which says that too much knowledge is not helpful.

If you get deeply into this you will learn that there are many different versions of Make, and that writing a complicated Makefile that works with multiple versions of Make on multiple platforms is ... hard. However, in the open source world, it is "best practice" to use tools such as automake, autoconf and so on to generate the makefiles, etc. If you do that, a lot of the version / platform related complexity is dealt with behind the scenes.

Finally, you tagged the question with "java". My take is that you shouldn't use make to build Java applications (unless you are building native code libraries as well). There are Java specific build tools that are much easier to use ... and do a better job than make. (Ant, Maven, and Gradle are obvious candidates.)


If you're working with open source or Unix-like operating systems, yes. Take heart though, they're not that complicated. Learning make will save you a lot of time in the long run.

  • Learning for reading or learning for writing?
    – user7043
    Aug 26, 2012 at 1:29
  • Both. You want to know how to read it so you can debug issues of software you use, or writing so that you can create your own.
    – EhevuTov
    Aug 26, 2012 at 2:08
  • Then I have to disagree with the writing part. There are plenty of other - arguably much better - ways to automate builds. Writing actually useful makefiles is far from trivial and not necessary.
    – user7043
    Aug 26, 2012 at 2:49

Makefiles are important on UNIX systems (e.g. AIX, Linux, OS X). However, I think that their absolute "you gotta know it" importance has diminished in recent years. For example, you don't really find them in Windows development (Visual Studio, etc.) and XCode (on OS X) uses a different system altogether. I'm not much into Java, but there I think they use ant files and whatnot.

There is a very cool system called CMake that generates native build files for the operating system that you happen to be running on. For example, if you write your project specification in CMake, then you can create a Visual Studio build project on Windows, an XCode project on Mac, and a Makefile on Linux. In a way, CMake replaces autoconf and automake.

I usually create CMake files for my "big projects" but I know Make in case I want to write a quick "just get it done" Makefile. It's good for your cultural literacy, because there are tons and tons of software libraries that use Makefiles, and you will inevitably need to edit the specific compilers and library locations. But you will find that big projects (like KDE) are migrating toward CMake and the like since Make does have some limitations that rear their ugly head when projects get complicated.

  • Learning CMake will be orders of magnitude more beneficial. Makefiles can be seen as an implementation detail - don't bother learning them (until really forced to), just like Visual Studio project files.
    – user44761
    Dec 23, 2012 at 22:44

I'm bias as i think makefiles are a terrible system. You should learn general syntax so you can modifying an existing makefile. But i don't think learning everything about it nor making one from scratch is useful.

  • Care to explain why makefiles are a terrible system? Compared to what?
    – JonnyJD
    Dec 23, 2012 at 1:48
  • @JonnyJD: One thing is I do not believe a good build system should have you put a make file in each sub directory. But its bad because its not much easier to use then writing a bat file which is really saying something.
    – user2528
    Dec 23, 2012 at 2:35
  • Sounds more like you don't like generating build files by hand. Which in itself is no big deal. Makefiles are a variant that should be possible to read and write manually. (modularized, only simplyfied the dependency tracking compared to bash/bat) The automated part is automake. The only thing that is actually much different is specifying dependencies in a GUI and saving all of this in one project file. Or what build system is that much less terrible?
    – JonnyJD
    Dec 23, 2012 at 3:00

As with many aspects of IDE output, a typical auto-generated makefile is often inefficiently structured.

With an appropriate level of understanding, it is often possible to significantly improve the performance (faster builds etc). However, unless you really know what's going on, you are more likely to FUBAR, when fiddling with an autogen-ed file.

I highly recommend being able to understand what is going on... whether you subsequently choose to start editing an existing one, or creating your own, is a separate issue.


Being able to successfully use make or something like it lets you check the "understands how to model the dependencies between parts of a program composed of more than one module" box.


Learning how to write Makefiles is a good idea for a number of reasons.

  1. Make is a language which lets you encode dependencies between components via rules. You will get a lot of experience with writing code this way, and it broadens your tools for thinking about solving programming problems.
  2. The principles you learn with Make can be used with Ant, Maven, and Rake if you choose to learn programming in the Java or Ruby world.
  3. Many IDEs have magic files which carry configuration information to help you build your software. If you don't believe me, try to write a script to build your software without the IDE. When you write your own Makefiles, you become very aware of the dependencies between your code, libraries, and your environment variables. As systems get larger, this turns out to be a useful tool for debugging your system.

You should always try to understand the build system you are using.

That does not necessarily mean you have to be able to create all of the build files by hand. The important part is understanding what the build system is doing for your project and the general ability to compile small projects manually (as in "typing commands on a terminal").

I just tend to think that creating (simple) Makefiles is the easiest step to understand what is going on, but you might have other means of understanding how to build things.

Why/when to learn Makefiles

If you keep programming for Windows only and don't expect anybody else to compile your code, feel free to compile the code how you like.

If you want to program compiler agnostic (as in "let others decide what compiler or IDE they want to use"), then you should learn another build system than just letting your IDE "deal with it".

If you want to program for different platforms, then you certainly need to use a widespread build system.

That still doesn't mean you have to know how the autogenerated Makefiles work in detail. You just have to know how the input files for the build system work. These just happen to have a similar syntax sometimes.

I personally really like Makefiles and use them for many things. Not just compiling code. I create a Makefile for every bigger pdf I create (with LaTeX) and every project I need to automate a couple of tasks in (building, packaging, uploading, updating dependencies from source repositories, pull/push manual backups)

However, I am working on the terminal a lot and I am working with Linux. I don't use what you would call an IDE other than vim (powerful text editor) and console tools. This might be very different for you.

If you ever complained about having to run different re-occuring commands just to "update"/package/upload/.. a "project", then learning how to write Makefiles might be something helpful for you.

If you have and use tools/GUIs/IDEs for everything, then you might not get anything out of that knowledge.

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