在运行configure时为与默认编译器不同的编译器进行配置

时间:2021-12-18 12:49:33

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.

我正在编译glibc库。在此之前,我需要运行configure。但是,对于编译glibc,我需要使用gcc编译器,它不是机器上的默认编译器。手册上写着以下内容。

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.

现在我的问题是,我在那台机器上没有任何管理权限。如何使用不同于默认的编译器。

4 个解决方案

#1


9  

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

在linux上,任何人都可以更改进程的环境变量;不需要行政权利。

In bash:

在bash中:

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

In csh use

在csh使用

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.

在这个shell中启动的任何程序在这个命令之后,在它的环境中都会有CC变量。(Env vars被bash、csh或其他shell记住)。您可以将此命令添加到~/中。bashrc文件使此设置永久。

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来配置,例如在bash中,可以将环境变量设置为单个命令,而不需要记住:

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)

PS和popular ./configure CC=gcc不是一个环境变量更改,并且是特定于配置实现的(但是大多数配置支持这个)

#2


2  

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

/configure将允许您设置编译器。

#3


1  

You can also do this when running make:

在运行make时也可以这样做:

make CC=/whatever/compiler

#4


0  

Do the following before running configure.

在运行configure之前执行以下操作。

export CC=gcc_your_version

#1


9  

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

在linux上,任何人都可以更改进程的环境变量;不需要行政权利。

In bash:

在bash中:

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

In csh use

在csh使用

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.

在这个shell中启动的任何程序在这个命令之后,在它的环境中都会有CC变量。(Env vars被bash、csh或其他shell记住)。您可以将此命令添加到~/中。bashrc文件使此设置永久。

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来配置,例如在bash中,可以将环境变量设置为单个命令,而不需要记住:

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)

PS和popular ./configure CC=gcc不是一个环境变量更改,并且是特定于配置实现的(但是大多数配置支持这个)

#2


2  

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

/configure将允许您设置编译器。

#3


1  

You can also do this when running make:

在运行make时也可以这样做:

make CC=/whatever/compiler

#4


0  

Do the following before running configure.

在运行configure之前执行以下操作。

export CC=gcc_your_version