"undefined reference to 'app_main'" compiling new project

Hi,
I am new to PIO, but not to programming. I setup a new project which is for an ESP32 (specifically ESP32-WROOM-32d DevKitCv4). I added the HX711 library from bogde.

I tried to compile everything using the “build” button on vscode, and got the following error:

[build] /Users/tennis/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/freertos/libfreertos.a(app_startup.c.obj):(.literal.main_task+0x24): undefined reference to `app_main'
[build] /Users/tennis/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/freertos/libfreertos.a(app_startup.c.obj): in function `main_task':
[build] /Users/tennis/esp/esp-idf/components/freertos/app_startup.c:199:(.text.main_task+0x99): undefined reference to `app_main'
[build] collect2: error: ld returned 1 exit status
[build] ninja: build stopped: subcommand failed.
[proc] The command: /usr/local/bin/cmake --build /Users/tennis/Documents/PlatformIO/Projects/waterbowl-esp32-c-hx711-weight-sensor/build --config Debug --target all -- exited with code: 1
[driver] Build completed: 00:00:33.382
[build] Build finished with exit code 1

I’ve made no code changes. Here is the content of my current main.c file:

void app_main() {}

Anyone have any ideas what I’m doing wrong?
TIA,
-T

Please show the content of your platformio.ini.

It looks like you are creating an ESP-IDF project (framework = espidf).
But the library you are referring to is an Arduino library.

Hi,

Here is my ini file:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = espidf
lib_deps = bogde/HX711@^0.7.5

I don’t think it is possible to use an Arduino library in a pure ESP-IDF project.

Hi @tennis.n.smith, the log in your first message is definitely not related to PlatformIO, you’re probably compiling it using the official plugin from Espressif.

1 Like

I found the problem. I was using the wrong “build” button. Once I switched to the checkmark PIO build button, it all works.

Thanks for all the suggestions.
-T