Include LVGL in existing makefile



i’m trying to port LVGL to an embedded system and while the instructions are crystal clear, i am struggeling a lot with makefiles. Whatever i do, i get this as compiler output:

main.c:(.text.startup.main+0x30): undefined reference to `lv_init'

Which means that the compiler is not able to find the right files, i think.
I’m always struggeling with makefiles but this is the first time i’m actually seeking help. I hope i can get some advice. Thank you in advance!

What MCU/Processor/Board and compiler are you using?

Embedded ARM 4 Cortex-A57, GCC

What do you want to achieve?

Successfully including LVGL into my project, port it to the system and use it.

What have you tried so far?

All kinds of possible INCLUDES, SOURCES & LIBS combinations (see screenshot).
LVGH is included like so: #include "lvgl/lvgl.h"

Code to reproduce

see above

Screenshot and/or video

Not a definite answer but maybe starting from the lv_port_linux_frame_buffer template helps. The Makefile is pretty minimal and I think the essential steps are really just

include $(LVGL_DIR)/lvgl/
include $(LVGL_DIR)/lv_drivers/

Ive looked at this template too but it just wouldnt work out for me. I just have no clue how to work with them properly. if i include

LVGL_DIR ?= ${shell pwd}
include $(LVGL_DIR)/lvgl/

i get:

root@c8d93a60a6bc:/home/lvgl# make
/home/lvgl/Makefile:43: /home/lvgl/build/lvgl/ No such file or directory
make[1]: *** No rule to make target '/home/lvgl/build/lvgl/'.  Stop.
make: *** [Makefile:170: build] Error 2

I dont understand why its searching in /home/lvgl/build/. its only searching there if the path above is correct. if i change it to something else, it stops searching in build. I am clearly executing the command from /home/lvgl. Its just confusing me.

Hm, any chance something else in your Makefile sets LVGL_DIR before? I think ?= only assigns the right hand side if the variable on the left hand side has not been set before.

No, its almost at the very top of my makefile. Its not declared twice.
Btw i was able to fix this issue right now by hardcoding /home/lvgl instead of using the shell pwd command. But now my main.c file is struggeling with the include #include "lvgl/lvgl.h"

Managed that by doing #include "../lvgl/lvgl.h"
But this doesnt seem right to me.

Also i am getting new compiler errors:

root@c8d93a60a6bc:/home/lvgl# make
linking lvgl.elf
/opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/11.1.0/../../../../aarch64-none-elf/bin/ld: /opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/11.1.0/../../../../aarch64-none-elf/bin/ld: DWARF error: can't find .debug_ranges section.
main.o: in function `main':
main.c:(.text.startup.main+0x30): undefined reference to `lv_init'
collect2: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/libnx/switch_rules:80: /home/lvgl/lvgl.elf] Error 1
make: *** [Makefile:170: build] Error 2

which is exactly the same compiler error that i had first

Could that be because you have the lvgl sources in lvgl/source/lvgl? At least it looks like that in your first screenshot.

It was the case when i made the screenshot, yes. But i’ve fiddled around a lot and now its not in there anymore (its one dir up). Im getting the same compiler errors though.

I found a semi-working repo, thus i will mark this as solved and create a new post for a different problem

Hello, Have you found solution? I have the same problem. If not could you share with this semi-working repo?