How often will a programmer be asked to write a makefile file? [closed]

送分小仙女□ 提交于 2019-12-22 04:42:58

问题


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


回答1:


Nobody 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 lucky enough to never deal with this, or who have managed to forget, IMakefile was a file that was sort of a meta-Makefile for X Window System based projects which would be used to generate a Makefile that knew where you'd installed all your X Windows libraries and binaries. Needless to say, it sucked.)




回答2:


Setting up a meaningful build system is part of the craft. I'd expect any non-super-junior developer to be able to come up with a makefile.




回答3:


As often as he is asked to start on a brand new project, which is not similar to an existing project whose builds scripts can be adapted. That is not a good answer I guess, but in my experience there has always been some code/resources/build scripts that I can adapt.

On a different note, for any C++ programmer, it is important to learn how his code is built. Makefiles, Ant scripts etc are just the implementation mechanism. So I think it is important enough to learn.




回答4:


Programmers need to know how to build their projects. Typically (in my experience) the 'production build' is based on the original programmer's makefile. Many programmers go their entire careers just fumbling blindly when putting together their makefiles, but every programmer has to do it.




回答5:


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

The frequency would depend on the platform that you're using and your role.

For example, in some organizations there is a fairly fixed build file that doesn't often change, while in others there are frequent changes. Some organizations rely on the IDE to deal with the build, etc. You don't have to be the build engineer.

I think that most C/C++ developers should have at least some fundamental understanding of how makefiles work, though they don't have to be gurus. In my alma mater, that is part of first-year CS.




回答6:


One thing to note is that, if the build system is set up in a modular way one practice isn't to build one huge makefile for the whole thing but makefiles for bits that can be called from the master makefile recursively. This is a great feature as it means different products (libraries?) can be built as separate units, often in parallel.

Makefiles are designed to automate the build process. Therefore, they are most definitely not a chore; they save you writing gcc -c *.c etc all the time. Not only that, but a properly written makefile has phonies for clean, rebuild etc. On most of my projects, make rebuild does exactly that - cleans everything and starts again.

Makefiles are really useful. I can't say that enough.




回答7:


Even if you are using an IDE that deals with the details of building the project for you, makefiles can still be very useful. Occasionally you need to have some extra functionality as part of your build process, for instance to run a pre-processing step to generate a c++ file programmatically (if you use Qt then you may need to run moc on your header files or rcc on your resource files. You might need to process an .idl file to generate an implementation file), or as a post-build step to copy files to a destination. In these cases you typically have two choices:

  • run the scripts as pre- or post-build steps every time, which means the app will be rebuilt every time you build it
  • create a makefile to perform the action which will embody the dependency rule so that the step will only be invoked if the timestamp of the input file is newer than that of the output file. Building a project that is already up to date will do nothing

A C++ developer may go for many years without needing to create a Makefile if they're not working on Linux/Unix, but a decent developer will seek to understand how Makefiles work as they will probably improve part of your current workflow.




回答8:


I suppose it depends...

Personally, I am quite mesmerized by the syntax of Makefiles. Doing any kind of even a simple operation on the paths of the object is ever so tricky.

On the other hand, being able to build is just necessary, and understanding the various arguments on the compile line is too. Though perhaps not for a junior.

I had to rewrite the build system of our application barely a year after I left school. I did it using scons and it worked great. Build time went from 1h30 to barely 10m because I was finally able to have parallel compilation and put an automatic local replication of the libraries used in place.

The morale is: if you ask someone to pick up a build mechanism, do not force Makefile on him. Let him pick a more recent tool.




回答9:


A powerful part of make is the shell code that you can write in each rule. So not only learning make is important, but understanding a shell language like bash and applying it to a project is very useful




回答10:


It depends on the tools/libraries/frameworks you are using for your project. For my job I code using Qt so I never have to write a Makefile as qmake does it for me although I do have to know how to create a qmake project file instead.

I freely admit I probably couldn't write anything beyond the simplest Makefile without having to learn it all from scratch. I don't see that changing anytime soon as I would only learn it if I was forced to. Why learn something you may never need?




回答11:


I haven't been asked to write a makefile in the last five years. Sometimes I could modify an existing makefile.

But when you have tools that make the job without the make program, it's not necessary to care for makefiles. Regarding your question, when a C++ programer has been asked for writing such a file: It depends.



来源:https://stackoverflow.com/questions/2556532/how-often-will-a-programmer-be-asked-to-write-a-makefile-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!