Configuring for a compiler different than the default while running configure

徘徊边缘 提交于 2019-12-18 06:54:50

问题


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.


回答1:


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)




回答2:


CC=gcc ./configure will allow you to set the compiler.




回答3:


You can also do this when running make:

make CC=/whatever/compiler



回答4:


Do the following before running configure.

export CC=gcc_your_version


来源:https://stackoverflow.com/questions/10435816/configuring-for-a-compiler-different-than-the-default-while-running-configure

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