linux - 如何使用 sudo yum install 安装 Fortran -dev 包

标签 linux gcc linker centos shared-libraries

我已经安装了 (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5) 并且 jave 也安装了 yum install gcc-gfortran 。 (封装gcc-gfortran-4.4.7-18.el6.x86_64)

但我收到如下错误:

/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [quadprog.so] Error 1

请帮助我安装 -lgfortran。看来我需要安装“提供 Fortran 库的 Fortran -dev 包”。我不知道如何在 RedHat/CentOS 中做到这一点。请帮忙。我在做这件事时遇到了困难。

我尝试使用以下方法安装 libgfortran:

yum install libgfortran

但是它说:

软件包 libgfortran-4.4.7-18.el6.x86_64 已经安装并且是最新版本 没事做 (在交互式 session 中运行,跳过干净的步骤。)

更多信息: 我尝试为 R 安装包 quadprog,下面是日志:

install.packages('https://cran.cnr.berkeley.edu/src/contrib/quadprog_1.5-5.tar.gz',dependencies = TRUE,repos = NULL,type ="source")
Installing package into '/usr/lib64/R/library'
(as 'lib' is unspecified)
trying URL 'https://cran.cnr.berkeley.edu/src/contrib/quadprog_1.5-5.tar.gz'
Content type 'application/x-gzip' length 33651 bytes (32 KB)
==================================================
downloaded 32 KB

* installing *source* package 'quadprog' ...
** package 'quadprog' successfully unpacked and MD5 sums checked
** libs
gfortran -m64  -fvisibility=hidden -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/lib64/gfortran/modules  -c aind.f -o aind.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG   -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic -fPIC   -c init.c -o init.o
gfortran -m64 -fvisibility=hidden -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/lib64/gfortran/modules -ffloat-store   -c -o solve.QP.compact.o solve.QP.compact.f
solve.QP.compact.f:254.3:

 72   if (nvl .EQ. 0) then                                              
   1
Warning: Label 72 at (1) defined but not used
solve.QP.compact.f:302.2:

 7       t1inf = .FALSE.                                                
  1
Warning: Label 7 at (1) defined but not used
solve.QP.compact.f: In function 'qpgen1':
solve.QP.compact.f:94: warning: 'it1' may be used uninitialized in this function
solve.QP.compact.f:98: warning: 't1' may be used uninitialized in this function
gfortran -m64 -fvisibility=hidden -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/lib64/gfortran/modules -ffloat-store   -c -o solve.QP.o solve.QP.f
solve.QP.f:245.3:

 72   if (nvl .EQ. 0) then                                              
   1
Warning: Label 72 at (1) defined but not used
solve.QP.f:293.2:

 7       t1inf = .FALSE.                                                
  1
Warning: Label 7 at (1) defined but not used
solve.QP.f: In function 'qpgen2':
solve.QP.f:85: warning: 'it1' may be used uninitialized in this function
solve.QP.f:89: warning: 't1' may be used uninitialized in this function
gfortran -m64  -fvisibility=hidden -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/lib64/gfortran/modules  -c util.f -o util.o
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -o quadprog.so aind.o init.o solve.QP.compact.o solve.QP.o util.o -L/usr/lib64/R/lib -lRblas -lgfortran -lm -lgfortran -lm -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [quadprog.so] Error 1
ERROR: compilation failed for package 'quadprog'
* removing '/usr/lib64/R/library/quadprog'
Warning message:
In install.packages("https://cran.cnr.berkeley.edu/src/contrib/quadprog_1.5-5.tar.gz",  :
  installation of package '/tmp/Rtmpry5XTG/downloaded_packages/quadprog_1.5-5.tar.gz' had non-zero exit status

编辑:

bash-4.1# rpm -ql libgfortran
/usr/lib64/libgfortran.so.3
/usr/lib64/libgfortran.so.3.0.0

最佳答案

你向我们展示了这个:

# type -a gcc

 gcc is /opt/centos/devtoolset-1.1/root/usr/bin/gcc 
 gcc is /usr/bin/gcc'

这意味着您已经安装了 Red Hat Developer Toolset 并使用 scl enable 或类似的命令为此 shell 启用了它。你还需要吗?如果没有,我建议禁用它。

如果您需要 DTS,则必须从 DTS 1.1 安装 Fortran 编译器,使用:

yum install devtoolset-1.1-gcc-gfortran

(或者直接从 here 下载它,这似乎是您获得 DTS 编译器的存储库。)

这将安装与您配置的 gcc 编译器兼容的 Fortran 编译器。没有它,系统 Fortran 编译器和 DTS gcc 一起使用,这不起作用,因为 DTS gcc 命令(用于在您引用的构建过程中进行链接)无法找到 libgfortran.so 来自系统 Fortran 编译器的库。

或者,您可以通过卸载 DTS 编译器使两个编译器同步:

yum install devtoolset-1.1-gcc-gfortran

关于linux - 如何使用 sudo yum install 安装 Fortran -dev 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45293476/

相关文章:

linux - 为什么当 kthread_run 失败时,linux 内核的 kref doc 会省略 kref_put

android - 运行HelloWorld cocos2dx失败

c - snprintf - 格式化不是字符串文字并且没有格式参数警告

c++ - 在 GCC/C++ 下访问 Windows 注册表

c - 以下代码中 XCode 输出和 gcc 输出之间差异如此之大的原因是什么?

c++ - boost 链接器错误 - 正则表达式 - C++

c - 编译 C(非 C++)OpenCV 代码时出现问题

linux - 如何告诉 CMake 将构建文件放在哪里?

linux - 由于系统中打开的文件太多,Kubernetes 无法启动

c++ - 链接器错误 - 从 C 文件调用 C++ 文件中的函数