Open zxslzx opened 2 months ago
Please share your lv_conf.h and main.c. How did you compile the project?
[main] Building folder: /home/ubuntu/Desktop/lvgl/build
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/ubuntu/Desktop/lvgl/build --config Debug --target all -j 10 --
[build] [ 45%] Built target lvgl
[build] [ 52%] Built target lvgl_thorvg
[build] [ 69%] Built target lvgl_demos
[build] [ 99%] Built target lvgl_examples
[build] [100%] Linking CXX executable ../bin/lvglsim
[build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function lv_sdl_window_create': [build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:86: undefined reference to
SDL_Init'
[build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:87: undefined reference to SDL_StartTextInput' [build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:89: undefined reference to
SDL_GetTicks'
[build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function lv_sdl_window_set_resizeable': [build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:144: undefined reference to
SDL_SetWindowResizable'
[build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function lv_sdl_get_disp_from_win_id': [build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:168: undefined reference to
SDL_GetWindowID'
[build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function lv_sdl_window_set_title': [build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:179: undefined reference to
SDL_SetWindowTitle'
[build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function lv_sdl_quit': [build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:191: undefined reference to
SDL_Quit'
[build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function sdl_event_handler': [build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:303: undefined reference to
SDL_Quit'
[build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:271: undefined reference to SDL_PollEvent' [build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function
window_create':
[build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:325: undefined reference to SDL_CreateWindow' [build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:329: undefined reference to
SDL_CreateRenderer'
[build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:341: undefined reference to SDL_SetWindowSize' [build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function
window_update':
[build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:353: undefined reference to SDL_UpdateTexture' [build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:355: undefined reference to
SDL_RenderClear'
[build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:358: undefined reference to SDL_RenderCopy' [build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:360: undefined reference to
SDL_RenderPresent'
[build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function texture_resize': [build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:382: undefined reference to
SDL_DestroyTexture'
[build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:396: undefined reference to SDL_CreateTexture' [build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:398: undefined reference to
SDL_SetTextureBlendMode'
[build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function res_chg_event_cb': [build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:435: undefined reference to
SDL_SetWindowSize'
[build] /usr/bin/ld: lib/liblvgl.a(lv_sdl_window.c.o): in function release_disp_cb': [build] /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:453: undefined reference to
SDL_DestroyTexture'
[build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:455: undefined reference to SDL_DestroyRenderer' [build] /usr/bin/ld: /home/ubuntu/Desktop/lvgl/lvgl/src/drivers/sdl/lv_sdl_window.c:456: undefined reference to
SDL_DestroyWindow'
[build] collect2: error: ld returned 1 exit status
[build] make[2]: [CMakeFiles/lvglsim.dir/build.make:104: ../bin/lvglsim] Error 1
[build] make[1]: [CMakeFiles/Makefile2:133: CMakeFiles/lvglsim.dir/all] Error 2
[build] make: *** [Makefile:130: all] Error 2
[proc] The command: /usr/bin/cmake --build /home/ubuntu/Desktop/lvgl/build --config Debug --target all -j 10 -- exited with code: 2
[driver] Build completed: 00:00:01.089
[build] Build finished with exit code 2
I tested under ubuntu20.04 , installed SDL2, error。
Have you installed SDL like this:
sudo apt-get install libsdl2-dev
I removed the if().... .elseif()... .endif. and it works!
cmake_minimum_required(VERSION 3.10)
project(lvgl)
#Uncomment if the program needs debugging
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb")
set(CMAKE_C_STANDARD 99) # LVGL officially supports C99 and above
set(CMAKE_CXX_STANDARD 17) #C17
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
add_subdirectory(lvgl)
target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR})
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2)
pkg_check_modules(SDL2_image REQUIRED SDL2_image)
target_include_directories(lvgl PRIVATE ${SDL2_INCLUDE_DIRS})
target_include_directories(lvgl PRIVATE ${SDL2_IMAGE_INCLUDE_DIRS})
add_executable(lvglsim main.c mouse_cursor_icon.c)
target_link_libraries(lvglsim lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} m pthread)
add_custom_target (run COMMAND ${EXECUTABLE_OUTPUT_PATH}/lvglsim DEPENDS lvglsim)
I've just tried it out and could reproduce the issue. You should call CMake like this: cmake -DLV_USE_SDL=1 ..
.
It's something that we really should document. There is also an LVGL issue to make CMake handling more unified. @etag4048 will work on it soon.
I tested under debian12, error occurred during startup, Segmentation fault.