将gcc设为make的默认编译器 [英] Make gcc the default compiler of make

查看:573
本文介绍了将gcc设为make的默认编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁知道如何使gcc而不是cc成为'make'的默认编译器?

anyone who knows how to make gcc instead of cc the default complier of 'make'?

例如,我有一个源代码xyz.c,并在我的Makefile中键入:

for example I have a source code xyz.c and in my Makefile I type:

CFLAGS=-Wall -g

全部:xyz

然后在终端上执行 make xyz ,并输出

and then on the terminal when I execute make xyz, and it outputs

cc -Wall -g xyc.c -o xyz

如何使gcc成为默认编译器?

How can I make gcc it's default compiler?

推荐答案

通常,您会执行以下操作:

Usually you do something like:

CC = gcc

然后是类似的东西:

$(CC) -Wall -g xyc.c -o xyz

这使您可以随时更改编译器,只需更改一行即可.请注意,有很多方法可以告诉make编译程序,因此除非提供完整的makefile,否则很难知道是使用自己的规则还是隐式规则等.

This allows you to change the compiler at any time by just changing the one line. Note that there are many ways to tell make to compile your program, so unless you provide the full makefile its hard to know if you're using your own rules or implicit ones, etc.

(要使答案更完整,我还要指向

(To make the answer more complete, let me also point to the manual pages reference by @lurker above, which give more information about other variables you might want to set.)

这篇关于将gcc设为make的默认编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆