esp32 bug记录:重复定义
FAILED: project-name.elf
cmd.exe /C "cd . && D:\Espressif\tools\xtensa-esp32-elf\esp-12.2.0_20230208\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32=0 -Wl,--Map=C:/Users/Administrator/Desktop/project-name/build/project-name.map -Wl,--no-warn-rwx-segments -fno-rtti -fno-lto -Wl,--gc-sections -Wl,--warn-common -T
esp32.peripherals.ld -T esp32.rom.ld -T esp32.rom.api.ld -T esp32.rom.libgcc.ld -T esp32.rom.newlib-data.ld -T esp32.rom.syscalls.ld -T esp32.rom.newlib-funcs.ld -T memory.ld -T sections.ld @CMakeFiles\project-name.elf.rsp -o project-name.elf && cd ."
d:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/peripheral/libperipheral.a(wifi_dis.c.obj):C:/Users/Administrator/Desktop/project-name/components/peripheral/include/wifi_dis.h:39: multiple definition of `wifi_connect_flag'; esp-idf/main/libmain.a(real_time_stats_example_main.c.obj):C:/Users/Administrator/Desktop/project-name/components/peripheral/include/wifi_dis.h:39: first defined here
d:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/peripheral/libperipheral.a(wifi_dis.c.obj):C:/Users/Administrator/Desktop/project-name/components/peripheral/include/wifi_dis.h:36: multiple definition of `wifi_sta_data'; esp-idf/main/libmain.a(real_time_stats_example_main.c.obj):C:/Users/Administrator/Desktop/project-name/components/peripheral/include/wifi_dis.h:36: first defined here
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
解决办法:头文件中包含了自身,去掉就好了,如图我的包含了wifi_dis.h
还不行就看下头文件有没有定义变量
放到c文件中
然后idf.py clean清除一下再编译