Integration external library compiling on Arduino

I have developing a app based on LVGL 8.3.3, using the editor SquareLine Studio 1.3.4, and the code generated is compiling by Arduino 2.2.1, the problem is using a external library (WiFi.h) in a event. I tried everything, insert the include <WiFi.h> in several files like (ui.h) (ui_events.h) (lv_conf.h), main INO file.
but compiling with Arduino always jump the next error:

“In file included from C:\Users\daniel.arguelles\Desktop\Arduinov1.2v1.2.ino:31:
C:\Users\daniel.arguelles\Desktop\Arduinov1.2\ui.h:11:1: note: ‘extern “C”’ linkage started here
extern “C” {
^~~~~~~~~~
In file included from c:\users\daniel.arguelles\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32s3-elf-gcc\esp-2021r2-patch5-8.4.0\xtensa-esp32s3-elf\include\c++\8.4.0\bits\shared_ptr.h:52,
from c:\users\daniel.arguelles\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32s3-elf-gcc\esp-2021r2-patch5-8.4.0\xtensa-esp32s3-elf\include\c++\8.4.0\memory:81,
from C:\Users\daniel.arguelles\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\WiFi\src/WiFiClient.h:26,
from C:\Users\daniel.arguelles\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\WiFi\src/WiFi.h:37,
from C:\Users\daniel.arguelles\Desktop\Arduino
v1.2\ui.h:15,
from C:\Users\daniel.arguelles\Desktop\Arduinov1.2v1.2.ino:31:
c:\users\daniel.arguelles\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32s3-elf-gcc\esp-2021r2-patch5-8.4.0\xtensa-esp32s3-elf\include\c++\8.4.0\bits\shared_ptr_base.h:1745:3: error: template with C linkage
template<typename _Tp, typename _Tp1>
^~~~~~~~
In file included from C:\Users\daniel.arguelles\Desktop\Arduinov1.2v1.2.ino:31:
C:\Users\daniel.arguelles\Desktop\Arduino*v1.2\ui.h:11:1: note: ‘extern “C”’ linkage started here
extern “C” {
^~~~~~~~~~”

The compiler complains about the usage of C++ features (template) inside the C linkage that was put between 'extern “C” {} by the SquareLine Studio exporter.
You might need to make functions somewhere else as wrapper/binding to call the wished C++ functions, some tips after a little bit of googling: How to call C++ function from C? - Stack Overflow

Solution

rename ui_events.c to ui_events.cpp.

Thanks

1 Like