How often will a programmer be asked to write a makefile?

Is makefile an advanced problem or a common problem for a programmer? For a C ++ programmer, how often will he be asked to write a makefile?

+7
c ++ compilation makefile
source share
11 answers

No one ever writes a Makefile. They take an existing Makefile and modify it.

Just be thankful you don't have to deal with IMakefile. (For those of you who were fortunate enough to never cope with this, or who managed to forget, IMakefile was a file that was a kind of meta-Makefile for projects based on the X Window System that would be used to create a Makefile that knew where you installed all your libraries and binaries are X Windows. Needless to say, this sucked.)

+24
source share

Setting up a meaningful build system is part of the ship. I would expect any non-super junior developer to be able to create a makefile.

+16
source share

As often as being asked to start with a completely new project that is not like an existing project whose build scripts can be adapted. This is not a good answer, I think, but in my experience there have always been some code / resource / assembly scripts that I can adapt.

In another note, for any C ++ programmer, it is important to find out how its code is built. Makefiles, Ant scripts, etc. They are just an implementation mechanism. Therefore, I think it is important enough to learn.

+4
source share

Programmers need to know how to build their projects. Usually (in my experience) the “build” is based on the programmer’s original makefile. Many programmers go all their careers, blindly following them when they collect their files, but every programmer must do this.

+2
source share

I never thought of makefiles as problems, they are quite useful ...

The frequency will depend on the platform used and your role.

For example, in some organizations there is a fairly fixed build file that does not change often, while in other cases frequent changes occur. Some organizations rely on an IDE to work with the assembly, etc. You do not have to be a construction engineer.

I think that most C / C ++ developers should have at least some fundamental understanding of how make files work, although they should not be gurus. In my alma mater, this is part of the first year of CS.

+1
source share

It should be noted that if the build system is configured in a modular way, one practice is not to create one huge makefile for everything, but makefiles for bits that can be called from the main makefile file recursively. This is a great feature, as it means that different products (libraries?) Can be built as separate blocks, often in parallel.

Makefiles are designed to automate the build process. Therefore, they are certainly not a choir; they save you spelling gcc -c *.c etc. all time. Not only this, but also a correctly written make file has backgrounds for cleaning, rebuilding, etc. In most of my projects, make rebuild does just that - cleans everything up and starts again.

Make files are really useful. I can’t say that enough.

+1
source share

Even if you use an IDE that deals with the details of building a project for you, makefiles can still be very useful. Sometimes you need to have some additional functions as part of the build process, for example, to start the preprocessing step to create a C ++ file programmatically (if you use Qt, you may need to run moc in your header files or rcc in your resource files. Perhaps , you will need to process the .idl file to create the implementation file) or as a step after assembly to copy the files to the destination. In these cases, you usually have two options:

  • Run scripts as steps of preliminary or post-assembly every time, which means that the application will be rebuilt each time it is created.
  • create a makefile to perform an action that will contain the rule of the rule , so the step will only be called if the timestamp of the input file is newer than the timestamp of the output file. Building a project that has already been updated will do nothing

A C ++ developer can work for many years without creating a Makefile if it does not work on Linux / Unix, but a decent developer will try to understand how Make files work, as they are likely to improve part of your current workflow.

+1
source share

I suppose it depends ...

Personally, I am quite hypnotized by the syntax of Make files. Performing even some simple operation on object paths is so complicated.

On the other hand, the ability to create is simply necessary, and understanding the various arguments on the compilation line also. Although perhaps not for the younger.

I had to rewrite the build system of our application only a year after I left school. I did this with scons and it did a great job. Build time increased from 1h30 to barely 10 m, because I was finally able to do parallel compilation and put automatic local replication of the libraries used in place.

Moral: if you ask someone to pick up the assembly mechanism, do not click on the Makefile . Let him choose a more recent instrument.

+1
source share

The powerful part of make is shell code, which you can write in each rule. Therefore, it is important not only to learn, but also to understand the shell language such as bash and apply it to the project, it is very useful

+1
source share

It depends on the tools / libraries / frameworks that you use for your project. I use Qt code for my work, so I don’t need to write a Makefile since qmake does this for me, although I need to know how to create a qmake project file.

I freely admit that I probably could not write anything but the simplest Makefile, without having to learn all this from scratch. I do not see this change in the near future, since I would only know it if I were forced to. Why learn something you never need?

0
source share

I have not been asked to write a make file in the last five years. Sometimes I can modify an existing make file.

But when you have tools that do the job without the make program, there is no need to take care of the makefiles. As for your question, when a C ++ programmer was asked to write such a file: it depends.

0
source share

All Articles