网上查到如何使用lvgl 支持freetype ,运行在arm板上,资料少之又少,官网的又有有点弄不明白,请求下8.2版本的lvgl怎么能支持freetype,我已经编译好了交叉编译好了freetype,生成了.so,也把头文件拷贝到lvgl/src/extra/freetype下了,但是编译不通过。
离线
@rf
同问这个问题,但是这个根本没人回答
离线
可参考下 https://gitee.com/zeepunt/lvgl_linux_simulator.git 的 commit log:[port] support freetype
最近编辑记录 pzh (2022-09-17 17:51:20)
离线
可参考下 https://gitee.com/zeepunt/lvgl_linux_simulator.git 的 commit log:[port] support freetype
请问一下,我编译报如下错误,你有遇到过嘛,那么编译通过后,又该怎么移植到实际板子上运行
CMake Error at CMakeLists.txt:18 (find_package):
By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "SDL2", but
CMake did not find one.
Could not find a package configuration file provided by "SDL2" with any of
the following names:
SDL2Config.cmake
sdl2-config.cmake
Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
"SDL2_DIR" to a directory containing one of the above files. If "SDL2"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/home/ubuntu/lvgl_linux/lvgl_linux_simulator/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found. Stop.
离线
@达子666
1、这个报错信息可以通过下面的命令安装 SDL 来解决
sudo apt install libsdl2-dev
2、如果实际的板子是运行发行版的 Linux,比如 Ubuntu Server,可以直接使用这个模拟器。
3、如果是自己通过 busybox + kernel + rootfs 构建的 Linux,那么就可以在服务器上通过交叉编译生成目标文件,再将目标文件放到板子上运行。
大概的过程是:
1)提供 /dev/fb0
2)修改 lvgl_linux_simulator/include/lv_drv_conf.h 文件
#ifndef USE_SDL
# define USE_SDL 0
#endif
...
#ifndef USE_FBDEV
# define USE_FBDEV 1
#endif
#if USE_FBDEV
# define FBDEV_PATH "/dev/fb0"
#endif
3)修改 src/lv_port.c 文件
void lv_port_disp_init(void)
{
/* 分配显示缓冲区 */
int buf_size = sizeof(lv_color_t) * SDL_HOR_RES * SDL_VER_RES;
buf_1 = malloc(buf_size);
buf_2 = malloc(buf_size);
if ((NULL != buf_1) && (NULL != buf_2))
lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, buf_size);
/* 默认初始化 */
lv_disp_drv_init(&disp_drv);
/* 缓冲区 */
disp_drv.draw_buf = &disp_buf;
/* 回调函数,需开发者提供,用于将缓冲区的内容复制到显示器的特定区域 */
disp_drv.flush_cb = ;
/* 显示器的水平分辨率,单位是像素 */
disp_drv.hor_res = ;
/* 显示器的垂直分辨率,单位是像素 */
disp_drv.ver_res = ;
/* 注册显示设备 */
disp = lv_disp_drv_register(&disp_drv);
}
4)修改 CMakeLists.txt 文件
/* 这里改为交叉编译工具链 */
set(CMAKE_C_COMPILER "/usr/bin/gcc")
...
/* 把下面的 SDL2 去掉 */
离线
我用的8.1
下载freetype-2.10.0
./configure CC=arm-linux-gnueabihf-gcc --host=arm-linux --prefix=$PWD/library --with-zlib=no --with-png=no
make
make install
lvgl makefile -- 参照
FREERTYPE_DIR ?= ../freetype-2.10.0
FREERTYPE_INCDIR ?= ../freetype-2.10.0/library/include/freetype2
FREERTYPE_LINK ?= ../freetype-2.10.0/library/lib
CFLAGS ?= -O3 -g0 -I$(LVGL_DIR)/ -I$(MIXML_DIR)/ \
-I$(FREERTYPE_INCDIR)/ -I$(FREERTYPE_LINK)/ \
-I$(FFMPEG_INDIR)/ -I$(FFMPEG_LINK)/ \
-Wall -Wshadow -Wundef \
-Wno-unused-function \
-fno-strict-aliasing -Wno-error=cpp \
-Wno-error=pedantic \
-Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated \
-Wempty-body -Wshift-negative-value -Wstack-usage=2048 -Wno-unused-value \
-Wuninitialized -Wmaybe-uninitialized \
-Wextra -Wno-unused-parameter -Wno-missing-field-initializers \
-Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral \
-Wpointer-arith -Wno-cast-qual -Wmissing-prototypes -Wunreachable-code \
-Wno-switch-default -Wreturn-type -Wmultichar -Wno-discarded-qualifiers \
-Wformat-security -Wno-ignored-qualifiers -Wno-sign-compare -O3
LDFLAGS ?= -lm -L$(FREERTYPE_LINK)/ -lfreetype \
-L$(FFMPEG_LINK)/ -lavformat -lavcodec -lavutil -lswscale -lm -lpthread
最近编辑记录 ronz (2022-09-21 15:54:15)
离线
@ronz
你用的是这里面的嘛,然后改一下makefile:
git clone https://github.com/lvgl/lv_port_linux_frame_buffer
离线
@ronz
你用的是这里面的嘛,然后改一下makefile:git clone https://github.com/lvgl/lv_port_linux_frame_buffer
/**
* @file lv_drv_conf.h
* Configuration file for v8.2.0
*/
/*
是的,8.2 我记错了
离线
@pzh
大佬编译了为啥一直报下面这种错误
home/ubuntu/lvgl_linux/lvgl_linux_simulator/src/lv_port.c: In function ‘lv_port_disp_init’:
/home/ubuntu/lvgl_linux/lvgl_linux_simulator/src/lv_port.c:34:5: warning: implicit declaration of function ‘fbdev_init’; did you mean ‘lv_init’? [-Wimplicit-function-declaration]
34 | fbdev_init();
| ^~~~~~~~~~
| lv_init
/home/ubuntu/lvgl_linux/lvgl_linux_simulator/src/lv_port.c:47:25: error: expected expression before ‘;’ token
47 | disp_drv.flush_cb = ;
| ^
/home/ubuntu/lvgl_linux/lvgl_linux_simulator/src/lv_port.c: In function ‘lv_port_indev_init’:
/home/ubuntu/lvgl_linux/lvgl_linux_simulator/src/lv_port.c:80:25: error: ‘sdl_mouse_read’ undeclared (first use in this function)
80 | indev_drv.read_cb = sdl_mouse_read;
| ^~~~~~~~~~~~~~
[ 51%] Building C object CMakeFiles/lvgl_linux.dir/assets/mouse_cursor_icon.c.o
[ 51%] Building C object CMakeFiles/lvgl_linux.dir/src/lv_port.c.o
/home/ubuntu/lvgl_linux/lvgl_linux_simulator/src/lv_port.c:12:10: fatal error: component/lv_drivers-8.3.0/display/fbdev.h: No such file or directory
12 | #include <component/lv_drivers-8.3.0/display/fbdev.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/lvgl_linux.dir/build.make:76: CMakeFiles/lvgl_linux.dir/src/lv_port.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:144: CMakeFiles/lvgl_linux.dir/all] Error 2
make: *** [Makefile:152: all] Error 2。
离线
达子666 说:@ronz
你用的是这里面的嘛,然后改一下makefile:git clone https://github.com/lvgl/lv_port_linux_frame_buffer
/**
* @file lv_drv_conf.h
* Configuration file for v8.2.0
*//*
是的,8.2 我记错了
可否帮忙分享一下源码,我搞了几天,还是没能成功。非常感谢
离线
离线
感谢
离线
贴主,您有解决这个问题吗
离线