错误:从 C 链接到 Fortran 库失败(从源代码编译八度音阶)

error: linking to Fortran libraries from C fails (compile octave from source)

提问人:sunxd 提问时间:10/27/2023 最后编辑:Cris Luengosunxd 更新时间:10/27/2023 访问量:51

问:

我尝试按照此处的说明在 Ubuntu 20.04 上从源代码编译八度音阶:

https://wiki.octave.org/Building

在此之前,我已经根据以下位置安装了依赖项:https://wiki.octave.org/Octave_for_Debian_systems

然后我收到以下错误

checking g++ compiler version number... 9.4.0
checking whether stl_algo.h is broken... no
checking gcc compiler version number... 9.4.0
configure: defining __NO_MATH_INLINES avoids buggy GNU libc exp function
checking for sin in -lm... yes
checking for gfortran... gfortran
checking whether the compiler supports GNU Fortran 77... yes
checking whether gfortran accepts -g... no
checking whether a usable Fortran compiler was found... yes
checking how to get verbose linking output from gfortran... -v
checking for Fortran 77 libraries of gfortran...  -L/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/x86_64-pc-linux-gnu/13 -L/home/linuxbrew/.linuxbrew/opt/glibc/lib -L/home/linuxbrew/.linuxbrew/lib/gcc/current -L/home/linuxbrew/.linuxbrew/lib -lgfortran -lm -lquadmath
checking for dummy main to link with Fortran 77 libraries... unknown
configure: error: in `/home/sunxd/octave-8.3.0/.build':
configure: error: linking to Fortran libraries from C fails

在config.log中,我发现

configure:18457: gcc -o conftest -g -O2   conftest.c -lm   -L/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/x86_64-pc-linux-gnu/     13 -L/home/linuxbrew/.linuxbrew/opt/glibc/lib -L/home/linuxbrew/.linuxbrew/lib/gcc/current -L/home/linuxbrew/.linuxbrew/lib -lgfortran -lm -lquadmath >&5     ¬                                                                                                                                                        
2160 /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':¬                                                   
2161 (.text+0x16): undefined reference to `__libc_csu_fini'¬                                                                                                  
2162 /usr/bin/ld: (.text+0x1d): undefined reference to `__libc_csu_init'¬                                                                                     
2163 collect2: error: ld returned 1 exit status¬                                                                                                              
2164 configure:18457: $? = 1¬                                                                                                                                 
2165 configure: failed program was:¬                                                                                                                          
2166 | /* confdefs.h */¬       

                             

使用(弗拉基米尔的建议)env |grep PATH

MANPATH=/home/linuxbrew/.linuxbrew/share/man:/home/linuxbrew/.linuxbrew/share/man::
WINDOWPATH=2
INFOPATH=/home/linuxbrew/.linuxbrew/share/info:/home/linuxbrew/.linuxbrew/share/info:
PATH=/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/sunxd/

我已经从 .profile 中注释掉了 linuxbrew 的脚本,但 linuxbrew 仍然存在。

# eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)

注销并重新登录 Linux Brew 现已离开。

根据 Ian 的建议,我摆脱了 f2c alreay。

现在配置通过了。

倍频程 配置

评论

2赞 Vladimir F Героям слава 10/27/2023
这是什么操作系统,MacOS?这个 fort77 包应该包含什么?请注意,根据配置输出,您已经拥有 gfortran。
3赞 Vladimir F Героям слава 10/27/2023
好的,我发现 fort77 是 f2c 的包装器。只要摆脱它,它就没用了。不要执着于配置中提到的 Fortran 标准的 77 修订版。忽略它,这是无关紧要的噪音。
3赞 Vladimir F Героям слава 10/27/2023
使用 GCC 9.4.0(相当旧,但可能是主要的发行版编译器套件)作为编译器,但与 GCC 13 中的库链接,您的 GCC 版本存在一些冲突。关于“为什么配置脚本会自动找到 homebrew 作为库路径?您必须向我们展示您的环境变量。执行并查看提到 linuxbrew 的位置。您可以使用 .envgrep
2赞 Ian Bush 10/27/2023
如果可以的话,也摆脱 f2c。那是从史前开始的,现在使用适当的编译器,即这个千年。
0赞 Cris Luengo 10/27/2023
请不要在标题中编辑“已解决”。相反,发布答案并接受它。请参阅此处:stackoverflow.com/help/self-answer

答: 暂无答案