解决各种 cannot find 编译器到底是怎么查找文件的?

要了解为什么找不到crti.o,或者编译器都找到了哪些路径,可以通过strace进行调查:

使用strace

你可以使用strace命令来跟踪编译命令执行时的系统调用,从而获得打开的文件路径信息。例如:
<BASH>
strace gcc <your_arguments> 2>&1 | grep crti.o

这将输出 gcc 执行过程中尝试打开crti.o文件的相关信息。

makefile添加 strace

####### Build rules

verifyspec:  $(OBJECTS)  
	strace  $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) 2>&1 | grep crti.o

结果

可以知道编译的时候它的搜索路径 只有 /lib/ /usr/lib 其他都不生效

genvict@genvict:~/rk3568_ubutnu/3rd/qt/qt-everywhere-src-5.15.10/config.tests/verifyspec$ make
strace  /opt/gcc-aarch64-linux-gnu-10.3.0/bin/aarch64-linux-gnu-g++ --sysroot=/home/genvict/rk3568_ubutnu/sysroot -Wl,-O1 -Wl,-rpath-link,/home/genvict/rk3568_ubutnu/sysroot/usr/lib -Wl,-rpath-link,/home/genvict/rk3568_ubutnu/sysroot/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/home/genvict/rk3568_ubutnu/sysroot/lib/aarch64-linux-gnu -Wl,-rpath-link,/home/genvict/rk3568_ubutnu/sysroot/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/home/genvict/rk3568_ubutnu/sysroot/lib/aarch64-linux-gnu -o verifyspec verifyspec.o   -lc -lm  -L/home/genvict/rk3568_ubutnu/sysroot/lib/aarch64-linux-gnu -L/home/genvict/rk3568_ubutnu/sysroot/usr/lib -L/home/genvict/rk3568_ubutnu/sysroot/usr/lib/aarch64-linux-gnu  2>&1 | grep crti.o
access("/opt/gcc-aarch64-linux-gnu-10.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/opt/gcc-aarch64-linux-gnu-10.3.0/bin/../lib/gcc/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/opt/gcc-aarch64-linux-gnu-10.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/aarch64-linux-gnu/8.3.0/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/opt/gcc-aarch64-linux-gnu-10.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/home/genvict/rk3568_ubutnu/sysroot/lib/aarch64-linux-gnu/8.3.0/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/home/genvict/rk3568_ubutnu/sysroot/lib/../lib64/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/home/genvict/rk3568_ubutnu/sysroot/usr/lib/aarch64-linux-gnu/8.3.0/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/home/genvict/rk3568_ubutnu/sysroot/usr/lib/../lib64/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/opt/gcc-aarch64-linux-gnu-10.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/home/genvict/rk3568_ubutnu/sysroot/lib/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/home/genvict/rk3568_ubutnu/sysroot/usr/lib/crti.o", R_OK) = -1 ENOENT (No such file or directory)
/opt/gcc-aarch64-linux-gnu-10.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crti.o: No such file or directory

解决

把库软连接到/home/genvict/rk3568_ubutnu/sysroot/lib/crti.o

genvict@genvict:~/rk3568_ubutnu/sysroot/lib$ ln -s aarch64-none-linux-gnu/crt1.o crt1.o
genvict@genvict:~/rk3568_ubutnu/sysroot/lib$ ln -s aarch64-none-linux-gnu/crti.o crti.o
genvict@genvict:~/rk3568_ubutnu/sysroot/lib$ ln -s aarch64-none-linux-gnu/crtn.o crtn.o
  • 16
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
FASMARM v1.42 This package is an ARM assembler add-on for FASM. FASMARM currently supports the full range of instructions for 32-bit and 64-bit ARM processors and coprocessors up to and including v8. Contents: 1. ARM assembly compatibility 2. UAL and pre-UAL syntaxes 3. IT block handling 4. Alternate encodings 5. Output formats 6. Control directives 7. Data definitions 8. Defining registers lists inside macros 9. Half-precision number formatting 10. Variants supported 11. Further information 12. Version history _______________________________________________________________________________ 1. ARM assembly compatibility There are a few restrictions how the ARM instruction set is implemented. The changes are minor and mostly have a minor impact. For the most part the basic instruction outline is the same. Where possible the original style is used but there are some differences: Not everything matches the ARM ADS assembly style, where possible the original style is used but there are some differences 1) label names cannot begin with a digit 2) CPSIE and CPSID formats are changed, use "iflags_aif" form instead of "aif" (eg. "CPSIE iflags_i" instead of "CPSID i") 3) SRS with writeback must have a separating space after the mode number and before "!" (eg. "SRSDB 16 !" instead of "SRSDB 16!") 4) macro, rept, irp, format, if, virtual etc. are all significant changes from the ARM ADS, so you will need to re-write those sections of existing code Original ARM Syntax | fasmarm Syntax ----------------------+---------------------- cpsie a | cpsie iflags_a | srsdb #29! | srsdb #29 ! ;or, | srsdb 29 ! _______________________________________________________________________________ 2. UAL and pre-UAL syntaxes fasmarm supports the original pre-UAL syntax and the newer UAL syntax. These two syntaxes only affect THUMB encodings. UAL stands for: Universal Assembly Language. pre-UAL syntax is selected wi

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

交叉编译之王 hahaha

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值