zl程序教程

您现在的位置是:首页 >  硬件

当前栏目

ESP8266 RTOS SDK “cannot find crt1-sim.o” 和error:‘CONFIG_AP_SSID_KEY‘ undeclared问题的解决

SDKap 解决 Error Cannot Key Find config
2023-09-11 14:21:25 时间

1. “cannot find crt1-sim.o” 问题

最近MBP换了SSD,重新装了系统,重新设置ESP8266开发环境后编译时遇到了cannot find crt1-sim.o的问题,完整错误信息如下:

/Users/esp8266/toolchain/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/5.2.0/../../../../xtensa-lx106-elf/bin/ld: cannot find crt1-sim.o: No such file or directory
/Users/esp8266/toolchain/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/5.2.0/../../../../xtensa-lx106-elf/bin/ld: cannot find _vectors.o: No such file or directory
/Users/esp8266/toolchain/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/5.2.0/../../../../xtensa-lx106-elf/bin/ld: cannot find -lsim
/Users/esp8266/toolchain/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/5.2.0/../../../../xtensa-lx106-elf/bin/ld: cannot find -lhandlers-sim
/Users/esp8266/toolchain/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/5.2.0/../../../../xtensa-lx106-elf/bin/ld: cannot find -lhal
collect2: error: ld returned 1 exit status
make[1]: *** [/Users/esp8266/esp-aliyun/examples/solutions/smart_light/build/bootloader/bootloader.elf] Error 1
make: *** [/Users/esp8266/esp-aliyun/examples/solutions/smart_light/build/bootloader/bootloader.bin] Error 2
make: *** Waiting for unfinished jobs....

折腾了一天毫无结果,过了两天决定重新搜索一下ESP8266_RTOS_SDK官方github页面的issue,终于在老旧的2018年的issue回答中找到了答案。

其实原因就是当前设置了LDFLAGS环境变量。查看LDFlags环境变量有两种方式:

  1. echo ${LDFLAGS}
  2. printenv | grep -i LDFLAGS

我运行上述命令的结果是:

LDFLAGS=-L/usr/local/opt/ruby/lib

解决办法也有两种:
3. unset LDFLAGS – 仅对当前终端有效
4. 查找的用户profile(我用zsh,所以我的当前用户profile的是~/.zshrc),删除LDFLAGS设定。我实际上找了半天,发现当前用户的profile里面没有这个设置。然后想了一下,当前用户是我新创建的一个专门用于编译ESP8266的新用户,终端窗口是从默认用户su esp8266登录的,所以回到默认用户的~/.zshrc里面删除LDFLAGS设定,开启新的终端窗口即可。

2. error: ‘CONFIG_AP_SSID_KEY’ undeclared (first use in this function)问题

这个问题解决起来比较简单,在项目主文件夹下运行make menuconfig,什么选项都不需要改动,然后再次编译就可以了。