1. 引入SDL驱动
SquareLine Studio导出的LVGL代码后如果要在windows上运行需要引入SDL的驱动,官方导出的代码是没有的,这里提供一个自己在网上找到的SDL2-2.28.1包,解压后放在同一目录下即可
2. 编写CmakeLists.txt
这里提供我这边自己修改的CmakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(lvglProject C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/SDL2-2.28.1)
find_package(SDL2 REQUIRED SDL2)
include_directories(
${SDL2_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS}/../
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/lvgl
${PROJECT_SOURCE_DIR}/lv_drivers
${PROJECT_SOURCE_DIR}/ui
)
file(GLOB_RECURSE LVGL_SOURCES CONFIGURE_DEPENDS lvgl/*.c)
file(GLOB_RECURSE LV_DRIVERS_SOURCES CONFIGURE_DEPENDS lv_drivers/*.c)
file(GLOB_RECURSE UI_SOURCES CONFIGURE_DEPENDS ui/*.c)
add_executable(${PROJECT_NAME} main.c ${LVGL_SOURCES} ${LV_DRIVERS_SOURCES} ${UI_SOURCES})
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
target_link_libraries(${PROJECT_NAME} PRIVATE ${SDL2_LIBRARIES})
3. 使用构建工具进行构建
我使用的是MingGW进行构建,正常会报错,这里需要在main.c这里添加一个宏
#define main SDL_main
然后可以构建出exe,但是如果直接运行的话会报错,因为少了SDL的动态链接库,这里文末也提供SDL的动态链接库的链接,直接放在和exe执行文件同一个目录下即可
标签:SquareLine,SDL2,windows,PROJECT,SOURCES,Studio,SOURCE,SDL,DIR From: https://www.cnblogs.com/yozima/p/18025241