Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

c - Configuring for a compiler different than the default while running configure

I am compiling the glibc library. Before I could do that, I need to run configure. However, for compiling glibc, I need to use the gcc compiler which is not the default compiler on the machine. The manual says the following.

It may also be useful to set the CC and CFLAGS variables in the environment 
when running configure. CC selects the C compiler that will be used, and CFLAGS 
sets optimization options for the compiler.

Now my problem is that I don't have any administrative rights on that machine. So how can I use a compiler different than the default.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

On linux anyone can change environment variables of his process; no administrative right are needed.

In bash:

export CC="gcc" CFLAGS="-O3 -Wall"

In csh use

setenv CC "gcc"

Any program started in this shell after such command will have CC variable in its environment. (Env vars are remembered by bash, csh or other shell). You can add this command to your ~/.bashrc file to make this setting permanent.

There are other ways to pass CC to configure too, e.g. in bash it is possible to set environment variable to single command, without remembering:

CC="gcc" CFLAGS="-O3 -Wall" ./configure ...

PS and popular ./configure CC=gcc is not an environment variable change and is specific to configure implementation (but most configures support this)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...