g77运行问题

g77运行问题

我按照之前问题中的步骤安装了 g77。但是当我运行它时出现了以下错误,你能帮我解决这个问题吗?

drjinasena@drjinasena-All-Series:~/minimum$ g77 sorting.f

/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status

谢谢

答案1

这两个问题有更详细的描述这里。但总体解决方案是:

“无法找到 crt1.o....”错误是一个已被讨论过的错误解决方法是找到 crti.o 在你的系统上的位置:

sudo find /usr/ -name "crti.o"

/usr/lib32/crti.o
/usr/lib/debug/usr/lib/x86_64-linux-gnu/crti.o
/usr/lib/x86_64-linux-gnu/crti.o
/usr/libx32/crti.o

选择包含“linux-gnu”的位置并将其添加到环境变量 LIBRARY_PATH。为此,请编辑 .bashrc 文件,然后重新加载它。即:

gedit ~/.bashrc

然后在最后添加:

LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH
export LIBRARY_PATH

(将路径替换为适合您系统的正确路径)。保存并退出文件,然后重新加载它:

source ~/.bashrc

“找不到 -lgcc_s” 表示 ld 找不到库 (libgcc_s)。您可以通过自己查找库来帮助它:

sudo find /usr/ -name libgcc_s.so

它为我返回了几个版本,因此我选择了最新版本(位于此处:“/usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so”),然后检查 ld 期望库的位置:

ld -lgcc_s --verbose

这返回了大量的文本,但我们感兴趣的主要部分就在最后:

==================================================
attempt to open /usr/x86_64-linux-gnu/lib64/libgcc_s.so failed
attempt to open /usr/x86_64-linux-gnu/lib64/libgcc_s.a failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libgcc_s.so failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libgcc_s.a failed
attempt to open //usr/local/lib64/libgcc_s.so failed
attempt to open //usr/local/lib64/libgcc_s.a failed
attempt to open //lib/x86_64-linux-gnu/libgcc_s.so failed
attempt to open //lib/x86_64-linux-gnu/libgcc_s.a failed
attempt to open //lib64/libgcc_s.so failed
attempt to open //lib64/libgcc_s.a failed
attempt to open //usr/lib/x86_64-linux-gnu/libgcc_s.so failed
attempt to open //usr/lib/x86_64-linux-gnu/libgcc_s.a failed
attempt to open //usr/lib64/libgcc_s.so failed
attempt to open //usr/lib64/libgcc_s.a failed
attempt to open //usr/local/lib/libgcc_s.so failed
attempt to open //usr/local/lib/libgcc_s.a failed
attempt to open //lib/libgcc_s.so failed
attempt to open //lib/libgcc_s.a failed
attempt to open //usr/lib/libgcc_s.so failed
attempt to open //usr/lib/libgcc_s.a failed
ld: cannot find -lgcc_s[/text]

如果我们从实际文件所在的位置建立到以下某个位置的符号链接,那么就大功告成了:

sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so /usr/lib/x86_64-linux-gnu/

相关内容