遇到的问题
在开发esp32蓝牙功能的时候,每次编译带有<BluetoothSerial.h>这个库都会报错
错误信息
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\airm2m_core_esp32c3\firmware.elf] Error 1
====================================================================================== [FAILED] Took 9.54 seconds ======================================================================================
源代码
#include <Arduino.h>
#include <BluetoothSerial.h>
BluetoothSerial SerialBT;
void setup() {
// put your setup code here, to run once;
Serial.begin(115200);
SerialBT.begin("ESP32");
SerialBT.setPin("1234");
Serial.printf("BT initial ok and ready to pair. \r\n");
}
void loop() {
// put your main code here, to run repeatedly;
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
delay(1);
}
详细报错内容
Processing airm2m_core_esp32c3 (platform: espressif32; board: airm2m_core_esp32c3; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/airm2m_core_esp32c3.html
PLATFORM: Espressif 32 (6.4.0) > AirM2M CORE ESP32C3
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 @ 3.20011.230801 (2.0.11)
- tool-esptoolpy @ 1.40501.0 (4.5.1)
- toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
Dependency Graph
|-- BluetoothSerial @ 2.0.0
Building in release mode
Linking .pio\build\airm2m_core_esp32c3\firmware.elf
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `.L0 ':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:713: undefined reference to `esp_spp_disconnect'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `_stop_bt':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:714: undefined reference to `esp_spp_deinit'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `.L0 ':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:189: undefined reference to `esp_spp_write'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:153: undefined reference to `esp_bt_gap_set_pin'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `.LVL229':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:652: undefined reference to `esp_bt_gap_register_callback'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `_init_bt':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:665: undefined reference to `esp_spp_register_callback'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:669: undefined reference to `esp_spp_init'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:675: undefined reference to `esp_bt_gap_set_security_param'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:675: undefined reference to `esp_bt_gap_set_cod'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `.LVL614':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:265: undefined reference to `esp_bt_gap_set_scan_mode'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `esp_spp_cb':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:271: undefined reference to `esp_spp_start_srv'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:283: undefined reference to `esp_spp_disconnect'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:364: undefined reference to `esp_spp_connect'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:385: undefined reference to `esp_spp_disconnect'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `.L0 ':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:126: undefined reference to `esp_bt_gap_resolve_eir_data'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `get_name_from_eir':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:130: undefined reference to `esp_bt_gap_resolve_eir_data'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `.L0 ':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:456: undefined reference to `esp_bt_gap_cancel_discovery'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\airm2m_core_esp32c3\lib821\libBluetoothSerial.a(BluetoothSerial.cpp.o): in function `esp_bt_gap_cb':
C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:458: undefined reference to `esp_spp_start_discovery'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:528: undefined reference to `esp_bt_gap_pin_reply'
c:/users/26900/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:/Users/26900/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src/BluetoothSerial.cpp:528: undefined reference to `esp_bt_gap_ssp_confirm_reply'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\airm2m_core_esp32c3\firmware.elf] Error 1
====================================================================================== [FAILED] Took 9.54 seconds ======================================================================================