lvgl / lv_port_pc_vscode

MIT License
217 stars 136 forks source link

x86_64-w64-mingw32/bin/ld.exe cannot find -lasan, cannot find -lubsan #38

Closed crack-dawn closed 2 months ago

crack-dawn commented 2 months ago

gcc version:build-info.txt

problems:

[build] [100%] Linking CXX executable J:\workplace_daily\lv_port_pc_vscode\bin\main.exe
[build] D:/toolchains/x86_64-13.2.0-release-win32-seh-ucrt-rt_v11-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lasan: No such file or directory
[build] D:/toolchains/x86_64-13.2.0-release-win32-seh-ucrt-rt_v11-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lubsan: No such file or directory
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make[2]: *** [CMakeFiles\main.dir\build.make:123: J:/workplace_daily/lv_port_pc_vscode/bin/main.exe] Error 1
[build] mingw32-make[1]: *** [CMakeFiles\Makefile2:109: CMakeFiles/main.dir/all] Error 2
[build] mingw32-make: *** [Makefile:135: all] Error 2

cmake build logs hinted that:

mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lasan: No such file or directory cannot find -lubsan: No such file or directory

kisvegabor commented 2 months ago

It seems MinGW doesn't really support ASAN. Does it work if you comment out these lines?

crack-dawn commented 2 months ago

By modify the projetc top cmakeList.txt in workplace root folder, I have solved the problem.

operatonal process:

  1. Without installing SDL2 library to Windows environment variables, I simply copy SDL2.dll to the bin folder and include its .h directories.
  2. Open the cmakeList.txt ,which is in project root dir; then modify find_package(SDL2 REQUIRED SDL2) into
    set(SDL2_PATH_TOP "${CMAKE_CURRENT_SOURCE_DIR}/thirdpart/SDL2-devel-2.28.2-mingw/SDL2-2.28.2/")
    find_package(SDL2 CONFIG HINTS "${SDL2_PATH_TOP}")
  3. Comment the last two lines in cmakeList.txt ,which is in project root dir;
    # target_compile_options(main PRIVATE -fsanitize=address,leak,undefined)
    # target_link_options(main PRIVATE -fsanitize=address,leak,undefined)
  4. after step 2 and 3, the modified cmakelist looks like this CMakeLists.txt
  5. Add #include "SDL2/SDL.h" in main.c

Prompt that the project has been built task completed successfully built , and the sample demo can run normally. image image