Undefined reference to `main'

This probably a well known build issue, I just need a bit of help to resolve this.

I’ve moved on from a Win10 environment to a Mac environment with the latest VSCode and PIO bits. I can build, run and debug the examples just fine.

I’ve downloaded the BLE LED example from here: PlatformIO Registry

I’ve added the following to my platformio.ini to get the example to build:

I’m getting the following linker error:
.pio/build/nrf52_dk/FrameworkMbed/rtos/source/TARGET_CORTEX/TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.o: In function __wrap_main': /Users/admin/.platformio/packages/framework-mbed/rtos/source/TARGET_CORTEX/TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c:77: undefined reference to main’

Am I missing another build flag?
Guidance is greatly appreciated.

The main() function is right there mbed-os-example-ble-LED - BLE LED control example | Mbed

What are the exact contents of your projects? Can you upload it somewhere for insepction?


This project doesn’t have any source code files. Can you donwload the repo (here) and add the source/ folder as src/ to the project?


how’s this?

The two source fiels must be in a folder called src/.

max@max-VirtualBox:~/mbed_BLE_LED_Project$ tree 
├── connection.png
├── discovery.png
├── LED_OFF.png
├── LED_ON.png
├── library.json
├── mbed_app.json
├── mbed-os.lib
├── module.json
├── platformio.ini
├── readme.md
├── scan_results.png
├── src
│   ├── LEDService.h
│   └── main.cpp
├── start_scan.png
├── Untitled.code-workspace
├── write_characteristic.png
└── write_pannel.png

compiles for me

max@max-VirtualBox:~/mbed_BLE_LED_Project$ pio run 
Linking .pio/build/nrf52_dk/firmware.elf
Checking size .pio/build/nrf52_dk/firmware.elf
Building .pio/build/nrf52_dk/firmware.hex
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=====     ]  49.3% (used 32288 bytes from 65536 bytes)
Flash: [=====     ]  47.0% (used 246552 bytes from 524288 bytes)

Note that due to ARM mbed: Compilation of project with long file paths not possible · Issue #2877 · platformio/platformio-core · GitHub, I wasn’t able to get compilation working on Windows, but Linux.


Derp! <— me LOL
Many thanks!

yes, issue #2877 is why I moved from Win10 to OS X

1 Like