如何使用多个GCC - LLVM和clang

时间:2012-06-14 06:27:09

标签: gcc llvm clang llvm-clang

在我的框中,我们以root用户身份安装了GCC 4.1.2但是为了编译LLVM和clang,我需要更高版本的GCC。所以我下载并在我的本地目录中安装了GCC 4.5.0

如何使现有程序参考GCC 4.5.0库和包含。

> gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> which gcc
/usr/bin/gcc

> setenv PATH gcc-4.5.0/bin/gcc/gcc-4.5.0/bin:$PATH

> gcc --version
gcc (GCC) 4.5.0
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> which gcc
gcc-4.5.0/bin/gcc/gcc-4.5.0/bin/gcc

只是设置系统PATH会对我有所帮助,还是我需要做些什么来让现有代码引用GCC 4.5.0套件?

gcc-4.5.0/bin/gcc/gcc-4.5.0/> ls -l
total 24
drwxrwxr-x 2 prasad ppusers 4096 Jun 13 21:32 bin
drwxrwxr-x 3 prasad ppusers 4096 Jun 13 21:32 include
drwxrwxr-x 3 prasad ppusers 4096 Jun 13 21:32 lib
drwxrwxr-x 2 prasad ppusers 4096 Jun 13 21:32 lib64
drwxrwxr-x 3 prasad ppusers 4096 Jun 13 21:32 libexec
drwxrwxr-x 6 prasad ppusers 4096 Jun 13 21:32 share

1 个答案:

答案 0 :(得分:1)

执行此操作的最佳方式因构建系统而异。

对于make(以及可能的其他系统),C编译器在CC变量中指定,因此您只需调用

CC=/path/to/new/gcc make

如果项目使用来自autoconf的配置脚本,则可以使用类似的

./configure CC=/path/to/new/gcc