以用户身份在 Linux 中安装 gfortran [英] Installing gfortran in Linux as a user

查看:83
本文介绍了以用户身份在 Linux 中安装 gfortran的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是工作中的 Linux (CentOS 6.6) 服务器的非管理员用户.我通过 Windows 计算机上的终端程序登录.我的问题是 IT 对我升级 GCC/gfortran 感到不舒服,所以我只想从我的个人文件夹中运行它.他们声称最新的 yum(此操作系统版本的 devtoolset-3)将降级他们拥有的一些其他功能.反正它不是最新版本的 GCC.

I am a non-administrator user of a Linux (CentOS 6.6) server at work. I log in through a terminal program on a windows computer. My problem is that the IT does not feel comfortable upgrading GCC/gfortran for me so I want to just run it from my personal folders. They claim the latest yum (devtoolset-3 for this OS version) will downgrade some other feature they have. It's not the latest version of GCC anyway.

我已经从 gfortran.com 下载了最新的 GCC 5.3 二进制文件和先决条件,并且几乎可以编译我的测试代码.实际上,当我执行以下操作时,它将使用 -c 编译但不会链接.该文件夹是我放置先决条件的地方,我也将/usr/lib64 目录中的内容复制到那里.

I have downloaded the latest GCC 5.3 binaries and prerequisites from gfortran.com and can almost get my test code to compile. Actually, when I do the following it will compile with -c but will not not link. That folder is where I put the prerequisites and also I copied stuff from the /usr/lib64 directory into there as well.

LD_LIBRARY_PATH=/users/home/me/me/gcc53mark/my_lib
export LD_LIBRARY_PATH
./gfortran test.f90 

错误信息如下:collect2:致命错误:找不到'ld'

The error message is as follows: collect2: fatal error: cannot find 'ld'

但 ld 确实存在

-bash-4.1$ whereis ld
ld: /usr/bin/ld /usr/share/man/man1/ld.1.gz

推荐答案

经过努力,我已经回答了我自己的问题!为了以非管理员身份将 GCC 安装到我自己的个人 Linux 帐户,我最终不得不编译 GCC,而不是使用我最初下载的二进制文件.我的朋友是 make install ,它知道所有东西都需要去哪里,而我在二进制文件中没有.

After much effort I have answered my own question! To install GCC to my own personal Linux account as a non-administrator, I ended up having to compile GCC and not use the binaries I originally downloaded. My friend was make install which knows where everything needs to go, which I did not have with the binaries.

关键是使用 build-it-yourself 方法 (-prefix) 提供的以下命令安装到我的用户根目录/GCC:

The key was to install to my user root directory /GCC with the following command provided with the build-it-yourself method (-prefix):

../gcc-5.3.0/configure --prefix$HOME/gcc-5.3.0 --enable-languages=c,c++,fortran --disable-multilib

对我来说,我不得不禁用 multilib,因为我猜我的系统只有 64 位库(我认为这导致了我最初的问题).

For me I had to disable multilib because I guess my system only has 64 bit libraries (I think this was causing my original problem).

在达到这一点之前,我还必须手动下载先决条件,因为我认为我的工作场所会阻止这些说明中提到的自动先决条件下载器.

Before I got to that point, I had to also download the prerequisites manually since my workplace I suppose blocks the automatic prerequisite downloader as referenced in these instructions.

https://gcc.gnu.org/wiki/InstallingGCC

需要从这里获取先决条件,将其放入解压缩 GCC 时创建的目录的根目录中.然后将它们解压缩并链接它们,就像在您已经解压缩的批处理文件中所做的那样 ./contrib/download_prerequisites.

Prerequisites need to be taken from here, placed into the root of the directory that gets created when you unzip GCC. Then unzip them and link them as is done in the batch file you have already unzipped ./contrib/download_prerequisites.

ftp://gcc.gnu.org/pub/gcc/infrastructure/

最后我需要运行以下命令,在它完成之后,它会查看新的库.当我准备好完全切换到本地较新版本时,我会将其添加到我的 .profile 中.

Finally I need to run the following command, after it is all up so it looks at the new libraries. I will add this to my .profile when I am ready to fully switch to the local newer version.

LD_LIBRARY_PATH=/users/home/myself/gcc-5.3.0/lib64
export LD_LIBRARY_PATH

目前我正在使用以下命令运行 gfortran,但稍后我会将其添加到我的 .profile 中.

For now I am running gfortran with the following command but also I will add this to my .profile later.

/users/home/myself/gcc-5.3.0/bin/gfortran Test.f90

有效!从我的本地 Linux 用户非管理员帐户运行的最新版本 GCC!

It works! Latest version of GCC running from my local Linux user non-administrator account!

编辑添加了我们如何为网络组解决此问题:IT 不想覆盖原始安装,所以我们安装到某个网络文件夹/gcc-5.3.0 .然后我们修改了组的 .profile 以在标准路径之前添加库和二进制路径.

Edited to add how we resolved this for the network group: IT did not want to overwrite the original installation so we installed to some network folder /gcc-5.3.0 . Then we modified the group's .profile to add the library and binary paths to that, before the standard path.

这篇关于以用户身份在 Linux 中安装 gfortran的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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