如何在Linux CentOS上更改默认的GCC编译器以用于MPI [英] How to change default GCC compiler to be used with MPI on Linux CentOS

查看:1104
本文介绍了如何在Linux CentOS上更改默认的GCC编译器以用于MPI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux(CentOS)机器上安装了两个GCC编译器。 GCC(4.4.7)的旧版本位于默认文件夹(随CentOS附带)中,而我打算使用的较新版本位于/usr/local/gcc/4.9.3/。我的代码使用了MPI和LAPACK / LAPACKE / BLAS库以及我用来编译源代码的旧GCC(例如main.cpp),如下所示:

mpiCC main.cpp -o main -L / home / USER1 / lapack-3.6.1 -llapacke -llapack -lblas -lm -Wall

仍然调用旧的GCC 4.4.7。我应该修改什么,以便上述MPI编译(mpiCC)从/usr/local/gcc/4.9.3/el6/bin/的新位置调用GCC 4.9.3可执行文件?


$ b $ MPICH安装程序指南3.2版(第6页):

MPICH配置步骤将尝试为您找到C,C ++和Fortran编译器,但如果您想要覆盖缺省值或需要指定配置无法识别的编译器,可以在命令行中指定它们[...]。例如,要选择英特尔编译器而不是GNU编译器一个系统,使用



./ configure CC = icc CXX = icpc F77 = ifort FC = ifort ... $ b

有没有办法在 ./configure 中的不同版本的GCC编译器之间进行区分? mpiCC 使用第一个 $ PATH 变量中找到gcc 编译器。



您应该能够设置新版本的gcc通过运行:

  PATH =/ usr / local / gcc / 4.9.3 / el6 / bin: $ PATHmpiCC main.cpp -o main -L / home / USER1 / lapack-3.6.1 -llapacke -llapack -lblas -lm -Wall 


I have two GCC compilers installed on a Linux (CentOS) machine. The old version of GCC (4.4.7) is in the default folder (came with CentOS) and the newer one that I intend to use is in /usr/local/gcc/4.9.3/. My code utilizes MPI and LAPACK/LAPACKE/BLAS libraries and with the old GCC I used to compile source (for example "main.cpp") like this:

mpiCC main.cpp -o main -L/home/USER1/lapack-3.6.1 -llapacke -llapack -lblas -lm –Wall

This still invokes the old GCC 4.4.7. What should I modify so the above MPI compilation (mpiCC) invokes GCC 4.9.3 executable from the new location at /usr/local/gcc/4.9.3/el6/bin/ ?

From MPICH Installer's Guide version 3.2 (page 6):

"The MPICH configure step will attempt to find the C, C++, and Fortran compilers for you, but if you either want to override the default or need to specify a compiler that configure doesn't recognize, you can specify them on the command line [...]. For example, to select the Intel compilers instead of the GNU compilers on a system with both, use"

./configure CC=icc CXX=icpc F77=ifort FC=ifort ...

Is there a way to dicriminate between different version of GCC compilers in ./configure ?

解决方案

I guess mpiCC uses the first gcc compiler found in the $PATH variable.

You should be able to set the new version of gcc by running:

PATH="/usr/local/gcc/4.9.3/el6/bin:$PATH" mpiCC main.cpp -o main -L/home/USER1/lapack-3.6.1 -llapacke -llapack -lblas -lm –Wall

这篇关于如何在Linux CentOS上更改默认的GCC编译器以用于MPI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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