I would like to be able to run the executable generated in the SLS VSCode Template project without this SDL2 Runtime error.
I have not changed anything in the template itself, just did the vscode export and have attempted to build and run.
$sqrline_cij_template_proj_vscode - ./build/SquareLine_Project_vscode
dyld[93399]: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2
Referenced from: <CDB6704D-6A89-3999-8057-A97757B88BF9> /Users/ianlaue/prospr/sqrline_cij_template_proj_vscode/build/SquareLine_Project_vscode
Reason: no LC_RPATH's found
zsh: abort ./build/SquareLine_Project_vscode
What have you tried so far?
Searched through every single forum that had any error close to the one I have found (at least ~100).
Double checked my SDL2 install brew install sdl2.
Debugged the CMakeLists.txt to make sure the include DIRS for SDL2 were correct.
Did a clean build.
For the SDL drivers, I cloned the entire lv_drivers from the LVGL repo
git clone https://github.com/lvgl/lv_drivers.git
Others
SquareLine Studio version: 1.3.4
Operating system: MacOS Sonoma 14.2.1
Target hardware: Only simulation for now
Edit
I just noticed that the INFO button in the project settings config in SLS links to the lv_port_pc_eclipse so maybe vscode isnāt supported out of the box?
It seems there are several issues with the 1.0.1 VScode board-template: lv_drivers folder is not included and you need to copy/clone, as you mentioned. The other culprit might be the default lv_conf.h which has duplicate definitions of LV_LAYER_SIMPLE_BUF_SIZE and LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE and that throws a lot of warnings, you can simply delete or comment out the latter of those. I didnāt try on macOS but on Linux there is a problem (freezing due to missing lv_tick_inc() call that LV_CUSTOM_TICK is needed to be set to 1 and LV_TICK_CUSTOM_INCLUDE to be set "SDL2/SDL.h" and LV_TICK_CUSTOM_SYS_TIME_EXPR to be set to (SDL_GetTicks()) in order for the timed main loop to work. And many times runtime-freezes can be prevented even better by setting LV_MEM_CUSTOM to 1 too.
This is a kind of runtime problem but Iām not sure about your runtime problem. Maybe try to set the above mentioned stuff in lv_conf.h and give another try. The board-template files will have a major update/expansion soon on our GitHub repo, will have more, better and more up-to-date templates.
If not solved by the above, LC_RPATH has something to do with relative/absolute path of the SDL runtime library. Maybe you need to copy the SDL library beside your generated executable or do some macOS related path or environment-variable settings, just a quick search on LC_RPATH vs CMake:
One more thing: VScode has a good CMake integration so when asked itās better to let CMake decide on the build-tools and not try an user guess firstā¦ (These CMake based VScode projects are typically buildable outside of VScode in plain commandline by ācmakeā and āmakeā command.)
From what I understand, this now sets @rpath == /Library/Frameworks/ which is then prepended to SDL2.framework/Headers which CMake knows exists because find_package(SDL2 REQUIRED SDL2).
Resulting in /Library/Frameworks/SDL2.framework/Headers
Step #3
Also, I can see how MacOS users can get frustrated after using the CMake config that is recommend by the SDL2 install README.md and then getting this @rpath issue.
After I solved the @rpath issue, my OS gave me a warning pop-up āSDL2.frameworkā canāt be opened because Apple cannot check it for malicious software.
sqrline_cij_template_proj_vscode/build āļø /sqrline_cij_template_proj_vscode/build/SquareLine_Project_vscode
dyld[85576]: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2
Referenced from: <D0D5E4A5-ECA0-30D5-BB60-EBAF588736C2> /sqrline_cij_template_proj_vscode/build/SquareLine_Project_vscode
Reason: tried: '/Library/Frameworks/SDL2.framework/Versions/A/SDL2' (code signature in <B2708AD2-6DD5-3F10-A549-A747A6814A62> '/Library/Frameworks/SDL2.framework/Versions/A/SDL2' not valid for use in process: library load disallowed by system policy), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/SDL2.framework/Versions/A/SDL2' (no such file), '/Library/Frameworks/SDL2.framework/Versions/A/SDL2' (code signature in <B2708AD2-6DD5-3F10-A549-A747A6814A62> '/Library/Frameworks/SDL2.framework/Versions/A/SDL2' not valid for use in process: library load disallowed by system policy), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/SDL2.framework/Versions/A/SDL2' (no such file)
I had to allow SDL2 to be used by via MacOS System Settings because it is not from an identified develop. Iām only allowed 2 links as a new user, so just google āstackoverflow how-do-i-override-the-malicious-software-check-for-the-sdl2-framework-on-macā