GNU Make值得学习吗?

发布于 2024-08-03 01:21:16 字数 1428 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

国粹 2024-08-10 01:21:16

Make 是所有 C/C++ 的标准构建工具。许多其他人也开始涉足这一领域,但即使他们有用且成功,他们也从未实现 make 的普及。

Make 几乎安装在所有类 Unix 机器上。无论您使用的是 AIX、Solaris、Irix、BSD 还是 Linux,只要安装了编译器,就会有 make。

一些“替换”(如 Automake、CMake)甚至创建 Makefile,然后由 make 执行。

绝对建议熟悉make。如果由花时间学习 make 的人来处理,它是一个强大的工具,可以通过多种方式使用,甚至不一定与软件开发相关。

即使您最终使用不同的构建工具,您也将能够“回收”从 make 中学到的经验教训,因为基本概念非常相似。大量的 make-built 项目意味着您总是有可能必须找出现有的 Makefile。

不过有一件事。 从一开始就做好。

Make is the standard build tool for everything C/C++. Many others have stepped to the plate, but even when they were useful and successful, they never achieved the ubiquity of make.

Make is installed on virtually every Unix-like machine out there. No matter if you're working with AIX, Solaris, Irix, BSD, or Linux, if there's a compiler installed, there's also make.

Some of the "replacements" (like Automake, CMake) even create Makefiles, which are in turn executed by make.

I would definitely recommend becoming familiar with make. If handled by someone who took the time to learn about make, it is a powerful tool, which can be used in a number of ways not even necessarily related to software development.

Even if you end up using a different build tool in the end, you will be able to "recycle" the lessons learned with make, as the underlying concepts are quite similar. And the sheer number of make-built projects means that there will always be the chance that you have to figure out an existing Makefile.

One thing, though. Get it right from the beginning.

溺孤伤于心 2024-08-10 01:21:16

我认为你没有看到 (GNU) make 的原因是它通常是默认的;如果你有 GNU 工具链,那么你就已经有了 make。因此,大多数开始谈论构建工具的人都会谈论其他事情。

根据我的经验,make 很好,但要让它完全按照你想要的方式做可能有点棘手。它可能有点神秘,但它已经被证明并且有效。

I think the reason you don't see (GNU) make mentioned is that it's often the default; if you have a GNU toolchain, you will have make already. Thus, most people that start talking about build tools, talk about something else.

In my experience, make is fine, but it can be kind of tricky to get it to do exactly what you want to. It's maybe slightly arcane, but it's proven and works.

街角迷惘 2024-08-10 01:21:16

Make 很受欢迎,因为它(主要)用于 Linux/*nix 项目中的 C/C++ 源代码,并且比您提到的任何其他工具都古老得多,因此它经受住了时间的考验并且很成熟。有点像焦油。

老实说,我只知道make。上面的其他工具可能更好,但是很多项目只使用基本的 Makefile,因此您最好至少了解一点它。不仅适用于您自己的工作项目,还适用于您在网上找到的大多数开源项目。

Make is popular because it's used (mainly) for C/C++ sources in Linux/*nix projects, and is far older than any of the other tools you've mentioned, thus it has stood the test of time and is mature. Kinda like tar.

To be honest with you, I only know make. Those other tools above may be better, but so many projects just use a basic Makefile that you're best off knowing at least a little bit of it. Not only for your own projects at work but most of the open-source ones you find on the net.

若水般的淡然安静女子 2024-08-10 01:21:16

这实际上取决于您将使用它的程度。

如果您经常使用 C/C++ make 项目,那么是的,我建议您更多地了解它,因为大型 make 文件比您提到的其他构建工具具有更陡峭的学习曲线。

如果您不使用 make,或者使用其他语言(例如 C#、Java 或 PHP),那么您最好学习与这些语言相关的构建工具。

It really depends how much you will use it.

If yoy work a lot with C/C++ make projects, then yes, I would recommend learning more about it as a large make file has a steeper learning curve than other build tools you mention.

If you don't work with make, or work in other languages such as C#, Java or PHP then you'd be better off learning build tools relevant to those languages.

风尘浪孓 2024-08-10 01:21:16

像所有工具一样,如果您要使用它,您应该花一些时间
变得相当熟练。此外,某些工具(例如 CMake)会生成 makefile,您可能有一天需要处理这些生成的文件。

GNU make 有一本优秀手册 - 它绝对值得花一个小时或两个人读它。

Like all tools, if you use it at all, you should put some time
into becoming reasonably adept at it. Also, some tools (like CMake, for example) generate makefiles and you may one day need to mess with those generated files.

GNU make has an excellent manual - it's certainly worth spendin an hour or two reading it.

成熟稳重的好男人 2024-08-10 01:21:16

例如,Make 是 Linux 系统上事实上的标准。它是一个非常复杂的工具,也是一个非常强大的工具。

如果您正在开发 C 或 C++,特别是针对 Linux/*nix,它非常适合学习。

make 的功能之一是您可以设置何时重建文件的依赖关系。例如,每个 c 或 c++ 文件都构建为 .obj 文件,最后,所有 .obj 文件都链接到可执行文件。但可执行文件可能是静态链接库,它与其他 .obj 文件链接到另一个可执行文件。

Make 可以确保编译时间尽可能短,因为您可以定义仅当 ac 文件或任何依赖头文件比 .obj 文件更新时才应编译 ac 文件。因此,仅当步骤的当前源文件比目标文件新时,才会执行任何编译或链接步骤。

例如,如果您使用 C# 进行开发,则不需要这种依赖性检查,因为所有 .cs 文件都会立即编译为单个可执行文件。

因此,结论是您应该使用非常适合您选择的编程语言的构建工具。

Make is the de-facto standard on Linux systems for example. It is a very complex tool, and also a very powerful tool.

It is well suited to learn if you are developing C or C++, particularly if targeting Linux/*nix.

One of the features of make, is that you can set up dependencies for when to rebuild a file. E.g. each c or c++ file is build into an .obj file, and in the end, all .obj files are linked to an executable. But maybe the executable is a statically linked library, that is linked into another executable with other .obj files.

Make can make sure that you compilation time is as short as possible, because you can define that a c file should only be compiled if it, or any dependent header files, are newer that the .obj file. So any compilation or linking step is only executed if the current source files for the step is newer that the target file.

If you are developing in for example C#, you don't need this kind of dependency checking because all .cs files are compiled at once into a single executable.

So the conclusion is that you should use a build tool that is well suited for your choice of programming language.

一杆小烟枪 2024-08-10 01:21:16

即使您最终更喜欢另一个构建工具(我个人喜欢 VS...我知道...),知道 make 可能会更有用。

Make 有许多应用程序,虽然它并不总是适合单个任务,但在处理新技术时它是坚固且灵活的。

Even if you end up preferring another build tool (personally I'm fond of VS... I know...) knowing make will probably prove more useful.

Make has many applications and whilst it is not always ideal for a single task, when dealing with new technologies it is stalwart and flexible.

就此别过 2024-08-10 01:21:16

我猜你工作的地方可能不同,但我知道,如果我至少没有学会如何阅读 Makefile,那么在我工作过的任何地方,我都将成为一名价值低得多的员工。即使在所有 Windows-VisualStudio 环境中,它也会时不时地出现。

例如,我们刚刚找到了一份工作,涉及将一堆旧的 CX/UX 代码移植到 Windows。旧代码是使用 makefile 构建的。如果不知道如何读取那些旧的 makefile,就无法理解他们的旧系统。

I guess where you work is probably different, but I know that everywhere I've worked I would have been a far less valuable employee if I hadn't at least learned how to read Makefiles. Even in all Windows-VisualStudio environments, it comes up every now and then.

For instance, we just got a job that involves porting a bunch of old CX/UX code to Windows. The old code was built with makefiles. There's no way to understand their old system without knowing how to read those old makefiles.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文