Pio test error: mbed_sdk_boot.c:112: undefined reference to `main'

Hi there!

I’ve set-up a new Visual Studio project for a Teensy 3.2 using:

pio init -b teensy31 --ide visualstudio

The project appears to have configured OK as the Teensy ‘mbed-blinky’ example builds and runs just fine.
However when I tried to run a simple Unity test against it I’m getting the following error:

pio test -vv
Collected 1 tests (*)

Processing * in teensy31 environment
Building & Uploading...
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy31.html
PLATFORM: Teensy (4.16.0) > Teensy 3.1 / 3.2
HARDWARE: MK20DX256 72MHz, 64KB RAM, 256KB Flash
DEBUG: Current (jlink) External (jlink)
 - framework-mbed @ 6.51506.201227 (5.15.6)
 - tool-teensy @ 1.155.0 (1.55)
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
Collecting mbed sources...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Unity @ 2.5.2
Building in test mode
Linking .pio\build\teensy31\firmware.elf
.pio/build/teensy31/FrameworkMbed/platform/source/mbed_sdk_boot.o: In function `__wrap_main':
C:\Users\lonney\.platformio\packages\framework-mbed\platform\source/mbed_sdk_boot.c:112: undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\teensy31\firmware.elf] Error 1

I’m not sure it has anything to do with the contents of the test as even just commenting out everything doesn’t change anything.

Is this something I’ve overlooked, or potentially a bug I need to raise elsewhere?



platform = teensy
board = teensy31
framework = mbed
board_build.mcu = mk20dx256
board_build.f_cpu = 72000000L
upload_protocol = teensy-cli

PlatformIO Core 6.1.7
Visual Studio Community 2022
Windows 10

Well, does one of your test sources define a main() function? The mbed framework needs it to be present in the firmware.

See platformio-examples/unit-testing/calculator/test/test_common/test_calculator.cpp at develop · platformio/platformio-examples · GitHub

Ah that was it, thanks! I think I accidentally used a testing example meant for Arduino, instead of mbed.