App_main not found "again"

Hi,

I gave PlatformIO a try 2 days ago and installed it, hoping to quickly repair a messed up ESP-IDF installation. Sadly I spent more time on PlatformIO than I would have needed to reinstall the IDF. Anyway, I like the idea of PlatformIO so I post my problems to find help.

I use VSC + PlatformIO, ESP32 Heltec board and IDF (NO Arduino).

I created a new project (intended to be shifted to CPP in order to try overloading and classes), consisting of one function and app_main().

ESP32
ESP-IDF
Heltec32 Board

/****************************************************************************************/
#include <stdint.h>

uint8_t test_overload(uint8_t a){
    a=a+1;
    return a;
}

extern "C" {
    void app_main(void);
}

void app_main(){
    uint8_t b;

    b=8;
    b=test_overload(b);
}
/*********************************************************************************************/

In VSC + PlatformIO I hit the clear symbol, then the flask symbol.

I get “undefined reference to ‘app_main’” no matter what I try.

All the hints, like “use extern C”, etc. do not work. Even downloading an example (ESP32_BLINK) gives the same problem.

Any ideas?

I hope that I just failed to understand something, as I am new to PlatformIO.

Hind regards
GvTT

You are executing the test task, which will ignore all source files in src/ and instead use the ones from test/. This folder is empty, thus your firmware is missing the app_main() function at link time.

It seems you’re executing the “Test” task instead of the “Build” and “Upload” tasks? Test is for unit testing.

1 Like

As Max pointed out, you want the tick (build) icon, not the flask :wink: See the following to see what each icon does.

https://docs.platformio.org/en/latest/ide/vscode.html#platformio-toolbar

Great, thank you very much!

You were absolutely right.
My apologies for not having read the instructions first.

Knowing I can compile my code I will read about using PlatformIO.

Compared to VSC + ESP-IDF I am surprised how easy the installation was.
Knowing my fault using it, I am impressed that my first compiles (C & CPP) worked right “out if the box”.
Now I can and will recommend using PlatformIO.
It will keep me busy while finding all the adjustments I might want to make - like specifying a different storage location, personal libraries, etc. I found this already covered in the forum.

A positive surprise,
many thanks to PlatformIO as well as to maxgerhardt and pfeerick
Georg

1 Like

Instructions… who needs to read the destructions? :laughing: Yes, it’s good to have docs.platformio.org and the forum bookmarked as I’m sure you’ll be visiting both a bit whilst acclimating yourself do a new IDE… I know I regularly visit the documentation, and often suggest edits, so don’t be afraid to point out any mistakes and make suggestions! :wink: