简体   繁体   English

在Mac上的终端中使用make编译代码

[英]Using make to compile code in c in terminal on Mac

I'm trying to learn to program in C and I'm getting used to compiling the code after writing it. 我试图学习用C语言编程,并且在编写代码后习惯于编译代码。 I'm actually using K&R 2nd edition to start off and they use 'cc' to compile. 我实际上是使用K&R 2nd Edition开始的,他们使用'cc'进行编译。 I originally started using Zed Shaw's Learn C The Hard Way but I've stopped because I haven't heard many good things about it. 我最初开始使用Zed Shaw的Learn C The Hard Way,但由于没有听到很多关于它的好消息,所以我停了下来。 Zed Shaw's way was to use 'make' to compile code, at least in the beginning. Zed Shaw的方法是至少在开始时使用“ make”来编译代码。

Is there any technical difference between using 'make' and using 'cc' that I should be concerned about right now? 我现在应该关注的使用“ make”和“ cc”之间是否存在技术上的区别?

make simply gives commands to the compiler, such as cc . make只是将命令提供给编译器,例如cc It automates building a project which has multiple files. 它可以自动构建具有多个文件的项目。 To begin, you do not need to concern yourself with those details. 首先,您无需担心这些细节。 Building a single file directly with cc is fine. 直接使用cc构建单个文件很好。 In fact, you will understand how the compiler works so that you can get the most out of make when you eventually learn it. 事实上,你会明白的编译器是如何工作的,这样你可以得到最有效地make ,当你最终学会它。

I agree with code-apprentice. 我同意代码学徒。 I would just add that it is important to have a good understanding of different cc command line options before moving on to make. 我想补充一点,在继续制作之前,对不同的cc命令行选项有一个很好的了解是很重要的。 When you reach the point of a more complexe compilation project and the build process of your final binary becomes a pain, that's when you can transition to learning Make! 当您达到了一个更复杂的编译项目的目的并且最终二进制文件的构建过程变得很痛苦时,那就是您可以过渡到学习Make的时候了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM