# SLS Exported VSCode Template Project - Runtime Error - dyld\[92608\]: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2

**URL:** <http://forum.squareline.io/t/sls-exported-vscode-template-project-runtime-error-dyld-92608-library-not-loaded-rpath-sdl2-framework-versions-a-sdl2/2336>\
**Category:** Bugs\
**Created:** [January 9, 2024, 5:09am UTC](http://forum.squareline.io/t/sls-exported-vscode-template-project-runtime-error-dyld-92608-library-not-loaded-rpath-sdl2-framework-versions-a-sdl2/2336 "2024-01-09T05:09:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurk](http://forum.squareline.io/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gurk](http://forum.squareline.io/u/gurk)\
**Post date:** [January 9, 2024, 5:09am UTC](http://forum.squareline.io/t/sls-exported-vscode-template-project-runtime-error-dyld-92608-library-not-loaded-rpath-sdl2-framework-versions-a-sdl2/2336/1 "2024-01-09T05:09:17Z")

</div>

### What do you want to achieve?

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.

```zsh
$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.

### Screenshot or video

 ![image](http://forum.squareline.io/uploads/default/original/2X/5/5b79e3377adc10c7ed1a733412d2a9b90dd5e39b.png)

SDL is enabled in lv\_conf.h

```c
#ifndef USE_SDL
# define USE_SDL 1
#endif

```

For the SDL drivers, I cloned the entire lv\_drivers from the LVGL repo

```zsh
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](https://github.com/lvgl/lv_port_pc_eclipse) so maybe vscode isn’t supported out of the box?

---

<div class="post-metadata">

**Author:** ![Hermit](http://forum.squareline.io/user_avatar/forum.squareline.io/hermit/32/971_2.png) [@Hermit](http://forum.squareline.io/u/Hermit)\
**Post date:** [January 10, 2024, 8:58am UTC](http://forum.squareline.io/t/sls-exported-vscode-template-project-runtime-error-dyld-92608-library-not-loaded-rpath-sdl2-framework-versions-a-sdl2/2336/2 "2024-01-10T08:58:44Z")

</div>

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:

> **[How to get an LC\_RPATH and @rpath/ prefix on a dylib on macos](https://discourse.cmake.org/t/how-to-get-an-lc-rpath-and-rpath-prefix-on-a-dylib-on-macos/5540)**
>
> Hi All, I’m trying to solve the apparently common problem on macos of getting cmake to do what I’m doing with install\_name\_tool. The common problem is that I link against 3rd party dylib, and at run-time the dylib is not found because it is not...

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.)

---

<div class="post-metadata">

**Author:** ![gurk](http://forum.squareline.io/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gurk](http://forum.squareline.io/u/gurk)\
**Post date:** [January 11, 2024, 5:55am UTC](http://forum.squareline.io/t/sls-exported-vscode-template-project-runtime-error-dyld-92608-library-not-loaded-rpath-sdl2-framework-versions-a-sdl2/2336/3 "2024-01-11T05:55:55Z")

</div>

First off, thank you for the detailed response! ~~ TLDR; I got it working!

**Step #1**

- Made updates to lv\_conf.h file
  - Comment out LV\_LAYER\_SIMPLE\_FALLBACK\_BUF\_SIZE
  - Set LV\_CUSTOM\_TICK == 1
  - LV\_TICK\_CUSTOM\_INCLUDE == “SDL2/SDL.h”
  - LV\_TICK\_CUSTOM\_SYS\_TIME\_EXPR == (SDL\_GetTicks())
  - LV\_MEM\_CUSTOM == 1

For a detailed view please use this [`git diff`](https://gist.github.com/ilaue-prospr/43e248135ce3954b4392309e564c15a5)

This helped get rid of all/most warnings during the build.  
This was required to get a working build with SDL2.

* * *

**Step #2**

- Added the solution from CMake forum detailed above
  - In CMakeLists.txt added after `add_executable` and before `target_link_libraries`

```auto
set_target_properties(${PROJECT_NAME} PROPERTIES BUILD_RPATH "/Library/Frameworks/" )

```

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](https://github.com/libsdl-org/SDL/blob/SDL2/Xcode/SDL/pkg-support/resources/ReadMe.txt#L24-L30) 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._

```auto
 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”

 ![allow_sdl2_run](http://forum.squareline.io/uploads/default/original/2X/0/0a63587947a55a16bc004f2c6ef509ffe08bb9f7.png)
