Page 1 of 1

Create and use external component

Posted: Mon Sep 23, 2024 6:00 pm
by Kniroxe
Hi, I'm trying to use the following component: "https://github.com/bitfixer/esp32s3vga/tree/main". I created the folder for components and made the necessary changes in the CMakeLists.txt to add it. The problem occurs when I try to build it: if I keep the main.c file as a C file, the compiler treats VGA.h as a C file as well and doesn't recognize the type name 'class'. However, if I change main.c to main.cpp, the compiler recognizes 'class' but then I get the error "undefined reference to 'app_main'".

I’m not sure why it won't let me compile in C++, even after changing the CMakeLists.txt to reference main.cpp. If anyone knows how to work with C++ files in this context, could you help me out?

Re: Create and use external component

Posted: Tue Sep 24, 2024 5:40 am
by nopnop2002
If you change main.c to main.cpp, the following changes are required.

https://docs.espressif.com/projects/esp ... splus.html

Re: Create and use external component

Posted: Tue Sep 24, 2024 7:35 am
by MicroController
Kniroxe wrote:
Mon Sep 23, 2024 6:00 pm
I get the error "undefined reference to 'app_main'".
Specifically, in C++, app_main() must be declared extern "C", see https://docs.espressif.com/projects/esp ... -main-in-c