简体   繁体   English

Linker 错误:未定义对 _fbss 的引用

[英]Linker error : undefined reference to _fbss

I'm sucessfully building pulp-riscv-gnu-toolchain from this this我从这个成功地构建了pull-riscv-gnu-toolchain

But when I try to compile my simple source code with builded compiler, error occured.但是当我尝试使用内置编译器编译我的简单源代码时,发生了错误。

My command is riscv32-unknown-elf-g++ -o hello hello.cpp我的命令是riscv32-unknown-elf-g++ -o hello hello.cpp

Error message is /home/jskim/test_toolchains_lib/gcc/riscv32-unknown-elf/7.1.1/../../../../riscv32-unknown-elf/bin/ld: cannot open linker script file riscv.ld: No such file or directory错误消息是/home/jskim/test_toolchains_lib/gcc/riscv32-unknown-elf/7.1.1/../../../../riscv32-unknown-elf/bin/ld: cannot open linker script file riscv.ld: No such file or directory

So I try with this command riscv32-unknown-elf-g++ -o main main.cpp -T /home/jskim/test_toolchains/riscv32-unknown-elf-ld/lib/ldscripts/elf32lriscv.x所以我尝试使用这个命令riscv32-unknown-elf-g++ -o main main.cpp -T /home/jskim/test_toolchains/riscv32-unknown-elf-ld/lib/ldscripts/elf32lriscv.x

But following error occured: /home/jskim/test_toolchains/lib/gcc/riscv32-unknown-elf/7.1.1/../../../../riscv32-unknown-elf/lib/crt0.o: In function '.L0': (.text+0x10):undefined reference to '_fbss' collect2: error: ld returned 1 exit status但出现以下错误: /home/jskim/test_toolchains/lib/gcc/riscv32-unknown-elf/7.1.1/../../../../riscv32-unknown-elf/lib/crt0.o: In function '.L0': (.text+0x10):undefined reference to '_fbss' collect2: error: ld returned 1 exit status

I'm using CentOS 7.6 and I try build this pulp-gcc with gcc 4.8.5 and 7.3.1 but both shows me same error.我正在使用 CentOS 7.6 并尝试使用 gcc 4.8.5 和 7.3.1 构建此纸浆-gcc,但两者都显示相同的错误。 Please help me.请帮我。

I resolve the problem in this way.我以这种方式解决问题。

Actually Here is the solution.实际上这是解决方案。 在此处输入图像描述

I'm not accurate but I think the problem is that the name is not matched.我不准确,但我认为问题在于名称不匹配。 crt0, which seems to be the helper of start riscv processor has this line la a0 _fbss just basically linker can recognize this if _fbss is replaced with _edata. crt0,这似乎是启动 riscv 处理器的助手,如果将 _fbss 替换为 _edata,则基本上la a0 _fbss可以识别这一行。 So i edit the assembly file which is located at pulp-riscv-gnu-toolchain/riscv-newlib/libgloss/riscv/ And rebuild the gnu toolchain.所以我编辑位于pulp-riscv-gnu-toolchain/riscv-newlib/libgloss/riscv/的程序集文件并重建gnu工具链。 And execute your compiler with -T option like riscv32-unknown-elf-g++ -o main main.cpp -T /home/jskim/test_toolchains/riscv32-unknown-elf-ld/lib/ldscripts/elf32lriscv.x并使用 -T 选项执行编译器,例如riscv32-unknown-elf-g++ -o main main.cpp -T /home/jskim/test_toolchains/riscv32-unknown-elf-ld/lib/ldscripts/elf32lriscv.x

This is the easiest solution as I think.这是我认为最简单的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未定义的参考链接器错误 - undefined reference linker error Linux上的链接器错误:“未定义引用” - Linker error on Linux: “undefined reference to” CUDA链接器错误:未定义对主引用 - CUDA linker error: undefined reference to main Linker 错误:未定义对“Reference_Genome::seq[abi:cxx11]”的引用 - Linker error: undefined reference to `Reference_Genome::seq[abi:cxx11]' 尽管使用了gcc链接器,但未获得汇编代码的“ _printf”错误的未定义引用 - Getting undefined reference to “_printf” error for assembly code despite using gcc linker 创建共享库链接器未定义的引用 - creating shared library linker undefined reference to 在链接器错误“未定义引用”的情况下,如何找到符号的调用例程? - How can I find the calling routine for a symbol in case of a linker error “undefined reference”? 尝试在Redhat计算机中构建应用程序并从链接器获取未定义的参考错误 - Trying to build application in redhat machine and getting undefined reference error from linker C ++链接器错误未定义对Linux上的类定义及其成员函数的引用 - C++ Linker error undefined reference to a class definition and its member functions on Linux 构建 PostgreSQL 时链接器错误“未定义对 SSL_get_peer_certificate 的引用” - Linker error "undefined reference to SSL_get_peer_certificate" when building PostgreSQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM