Linker Errors using BluetoothSerial

I have a simple Bluetooth project where I am simply trying to send strings out. I have verified that PIO and packages are all up to date and even forced a manual install of BluetoothSerial.h. My problem is that while the build completes, the linker throws a long list of errors. Below is my main.cpp, platformio.ini and a sample of the long list of linker errors.

I hope someone can tell me how to fix this!

main.cpp:

#include <Arduino.h>
#include <BluetoothSerial.h>

BluetoothSerial SerialBT;

void setup()
{
Serial.begin(115200);
SerialBT.begin(“ESP32-Server”);
}

void loop()
{
// Send data to the connected device
SerialBT.println(“Hello from ESP32!”);
delay(1000);
}

platformio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200

Some of the long list of linker errors:

c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZL8_stop_btv+0x18): undefined reference to `esp_spp_disconnect'
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZL8_stop_btv+0x1c): undefined reference to `esp_spp_deinit'   
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZL16_spp_send_bufferv+0x8): undefined reference to `esp_spp_write'
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZL8btSetPinv+0xc): undefined reference to `esp_bt_gap_set_pin'c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZN15BluetoothSerial5beginE6Stringb+0x24): undefined reference 
to `esp_bt_gap_register_callback'        
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZN15BluetoothSerial5beginE6Stringb+0x28): undefined reference 
to `esp_spp_register_callback'
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZN15BluetoothSerial5beginE6Stringb+0x2c): undefined reference 
to `esp_spp_init'
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZN15BluetoothSerial5beginE6Stringb+0x30): undefined reference 
to `esp_bt_gap_set_security_param'       
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZN15BluetoothSerial5beginE6Stringb+0x34): undefined reference 
to `esp_bt_gap_set_cod'
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZL10esp_spp_cb18esp_spp_cb_event_tP18esp_spp_cb_param_t+0x28): undefined reference to `esp_bt_gap_set_scan_mode'
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZL10esp_spp_cb18esp_spp_cb_event_tP18esp_spp_cb_param_t+0x2c): undefined reference to `esp_spp_start_srv'
c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZL10esp_spp_cb18esp_spp_cb_event_tP18esp_spp_cb_param_t+0x30): undefined reference to `esp_spp_connect'c:/users/al testani/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\lib9cf\libBluetoothSerial.a(BluetoothSerial.cpp.o):(.literal._ZL13esp_bt_gap_cb21esp_bt_gap_cb_event_tP21esp_bt_gap_cb_param_t+0x20): undefined reference to `esp_bt_gap_resolve_eir_data'

More information:

I am finding that BluetoothSerial.c tries to include the following:

#include “esp_bt.h”
#include “esp_bt_main.h”
#include “esp_gap_bt_api.h”
#include “esp_bt_device.h”
#include “esp_spp_api.h”
#include <esp_log.h>

The BluetoothSerial library is here:
...\.platformio\packages\framework-arduinoespressif32\libraries\BluetoothSerial

but the header files above are located here:
...\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\include\bt\host\bluedroid\api\include\api

How is that supposed to work?

You did not specify a platform version. Which platform version(s) is / are installed on your system?

I have no issues here with platform = espressif32 @ 6.8.1

To check the installed platform versions, click on PIO-Icon / Platforms / Installed. Filter the Platforms for “Espressif 32”

The cause might be the space in your user name. This is (or at least was) a known “limitiation”. Try a username without space / special characters or move the .platformio folder to a different path without spaces / special characters by changing the PLATFORMIO_CORE_DIR.

Interestingly, I have TWO Espressif 32 platforms installed. One is version 6.1.0 and the other is 2023.2.0.0. Also, if I filter on “Espressif 32” nothing is found but if I filter on “Espressif” the 2 platforms above are shown.

I uninstalled both and installed v6.8.1. Problem Solved! Thank you!!!