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

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

问题描述

我是Linux(CentOS 6.6)服务器的非管理员用户。我通过Windows电脑上的终端程序登录。我的问题是,IT部门对于我升级GCC / gfortran并不舒服,所以我想从我的个人文件夹中运行它。他们声称最新的yum(这个操作系统版本的devtoolset-3)会降低他们的一些其他功能。它不是GCC的最新版本。



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

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

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

但ld确实存在 p>

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


解决方案

我自己的问题!要以非管理员身份将GCC安装到我自己的个人Linux帐户中,我最终不得不编译GCC而不使用最初下载的二进制文件。我的朋友是make install,它知道一切都需要去哪里,我没有用二进制文件。



关键是安装到我的用户根目录/ GCC中(-prefix)提供的以下命令:

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

对于我来说,我必须禁用multilib,因为我猜我的系统只有64位库(我认为这是我原来的问题)。



在此之前,我必须手动下载先决条件,因为我的工作场所我认为会阻止自动先决条件下载程序,如本指南中所述。

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

先决条件需要从这里取出,放入解压缩GCC时创建的目录的根目录下。然后解压缩并链接它们,就像已经解压到./contrib/download_prerequisites的批处理文件中一样。

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

最后,我需要运行以下命令,它完成后,它看起来在新的库。

  LD_LIBRARY_PATH = / users /我将添加到我的.profile文件中,当我准备好完全切换到本地新版本时。 home / myself / gcc-5.3.0 / lib64 
export LD_LIBRARY_PATH

现在我是

  / users / home / myself / gcc使用以下命令运行gfortran,但也会在稍后添加到我的.profile中。 -5.3.0 / bin / gfortran Test.f90 

它的工作原理!最新版本的GCC从我的本地Linux用户非管理员帐户运行!

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


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.

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 

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

But ld does exist

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

解决方案

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.

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

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

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/

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

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

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

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天全站免登陆