espressif / esp-aliyun

Aliyun Iotkit-embedded, support esp32 & esp8266.
339 stars 151 forks source link

Ubuntu 20: undefined reference to `pthread_create' #209

Open losingrose opened 3 years ago

losingrose commented 3 years ago

1. 开发环境

Ubuntu 20

2. 问题描述

make编译失败。最后报错找不到pthread_create

Generating esp8266.project.ld LD build/smart_light.elf /home/losingrose/esp/esp-aliyun/examples/solutions/smart_light/build/esp-aliyun/libesp-aliyun.a(wrapper_os.o):(.literal.HAL_ThreadCreate+0x4): undefined reference to pthread_create' /home/losingrose/esp/esp-aliyun/examples/solutions/smart_light/build/esp-aliyun/libesp-aliyun.a(wrapper_os.o):(.literal.HAL_ThreadDelete+0x0): undefined reference topthread_exit' /home/losingrose/esp/esp-aliyun/examples/solutions/smart_light/build/esp-aliyun/libesp-aliyun.a(wrapper_os.o):(.literal.HAL_ThreadDelete+0x4): undefined reference to pthread_cancel' /home/losingrose/esp/esp-aliyun/examples/solutions/smart_light/build/esp-aliyun/libesp-aliyun.a(wrapper_os.o):(.literal.HAL_ThreadDelete+0x8): undefined reference topthread_join' /home/losingrose/esp/esp-aliyun/examples/solutions/smart_light/build/esp-aliyun/libesp-aliyun.a(wrapper_os.o): In function HAL_ThreadCreate': /home/losingrose/esp/esp-aliyun/wrappers/wrapper_os.c:267: undefined reference topthread_create' /home/losingrose/esp/esp-aliyun/wrappers/wrapper_os.c:267: undefined reference to pthread_create' /home/losingrose/esp/esp-aliyun/examples/solutions/smart_light/build/esp-aliyun/libesp-aliyun.a(wrapper_os.o): In functionHAL_ThreadDelete': /home/losingrose/esp/esp-aliyun/wrappers/wrapper_os.c:267: undefined reference to pthread_exit' /home/losingrose/esp/esp-aliyun/wrappers/wrapper_os.c:267: undefined reference topthread_cancel' /home/losingrose/esp/esp-aliyun/wrappers/wrapper_os.c:267: undefined reference to `pthread_join' collect2: error: ld returned 1 exit status make: *** [/home/losingrose/esp/ESP8266_RTOS_SDK/make/project.mk:510:/home/losingrose/esp/esp-aliyun/examples/solutions/smart_light/build/smart_light.elf] 错误 1

ESP-YJM commented 3 years ago

有没有先执行make chip=esp8266 defconfig, 执行这个会打开 CONFIG_ENABLE_PTHREAD。https://github.com/espressif/esp-aliyun/blob/master/examples/solutions/smart_light/sdkconfig_esp8266.defaults#L2

losingrose commented 3 years ago

执行后OK了,感谢你的回复。 开始被SDK和工具链的版本对应折腾了好几天,都快放弃了,使用make aliyun搞懂版本对应以后,感觉就快成功了,心急了。 希望能在文档中加一个 代码版本-SDK版本-工具链版本 的对应说明,对于新手来说很难能找到对应关系。