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
环境变量有两种方式:
echo ${LDFLAGS}
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
,什么选项都不需要改动,然后再次编译就可以了。