It sounds like you have found the problem. The fix will be harder I’m afraid.
Basically, In plain C, if you write a function called “Xxx(int x)” then the linker will look for a module containing the function called “Xxx”, regardless of the number and type of parameters the function takes.
In C++, however, you can overload functions so that they take different parameter types etc. In this case, the function name will be “mangled”, so “Xxx(int x)” and “Xxx(long y)” will have different names. It’s usually based on the parameter types. The linker will look for the module containing the appropriate function, with the correct mangled name, to suit the parameters passed in the actual function call.
If you have code written in C, which you need to use in a C++ application, you need to define the calling convention as extern "C" {...}
so that the compiler doesn’t mangle the names, and so that C++ can call the plain C functions – which might be in a library that you don;t have source for.
So, your C++ application needs to #include
all it’s own required C++ headers and C++ library headers as if the plain C stuff wasn’t being used.
It then also needs to do something like:
#ifdef __cplusplus
extern "C" {
#endif
// All the required C stuff here. This can be function declarations, function definitions, variables etc
#ifdef __cplusplus
}
#endif
What you must avoid is having anything related to C++ within the extern "C"
braces, otherwise, you will get the errors that are plaguing you.
lvgl/lvgl claimes to be Written in C and compatible with C++ so I suspect you need something like this:
#ifdef __cplusplus
extern "C" {
#endif
#include <lvgl.h>
#ifdef __cplusplus
}
#endif
But I don’t use lvgl, so I might be wrong here.
Oh, there’s a C++ wrapper for lvgl at GitHub - vpaeder/lvglpp: A C++ wrapper for LVGL whihc might be useful?
HTH
Cheers,
Norm.