1、问题现象
最近学习ESP8266的smartconfig功能,写了个测试代码在user_main文件中,结果编译时报错
/mnt/Share/ESP8266_NOS_T/app/user/user_main.c:205: undefined reference to `smartconfig_set_type'
/mnt/Share/ESP8266_NOS_T/app/user/user_main.c:206: undefined reference to `smartconfig_start'
/mnt/Share/ESP8266_NOS_T/app/user/user_main.c:211: undefined reference to `smartconfig_stop'
/mnt/Share/ESP8266_NOS_T/app/user/user_main.c:180: undefined reference to `smartconfig_stop'
2、查找原因
检查头文件包含情况 ,这几个函数在smartconfig.h中声明,在libsmartconfig.a中封装。刚开始怀疑是包含层次出了问题,检查后发现不存在包含层次问题。
这个问题困扰了几天,知道肯定是makefile出的问题,但是不知道如何下手,后来想到了他的example里面不是有smartconfig例子么,就打开看了下readme就知道问题原因了,里面有这么句:
if you want to use AIRKISS2.0 LAN discovery, should include airkiss.h and include libairkiss.a in makefile
然后打开他的makefile看了下:
LINKFLAGS_eagle.app.v6 = \
-L../lib \
-nostdlib \
-T$(LD_FILE) \
-Wl,--no-check-sections \
-Wl,--gc-sections \
-u call_user_start \
-Wl,-static \
-Wl,--start-group \
-lc \
-lgcc \
-lhal \
-lphy \
-lpp \
-lnet80211 \
-llwip \
-lwpa \
-lcrypto \
-lmain \
-ljson \
-lssl \
-lupgrade \
-lsmartconfig \
-lairkiss\
$(DEP_LIBS_eagle.app.v6) \
-Wl,--end-group
果然里面有lsmartconfig这个包含进去了,果断修改后,问题解决了,主要还是自己对makefile的编译链接过程不是全明白,因此下决心学习makefile