Lvgl simulator on macos ventura

Have new macbook pro and installed vscode, platformio and SDL2 via brew. However brew installed into /opt/homebrew. On my old computer there was a /usr/local/include directory that had SDL/SDL2.h. The SDL/SDL2.h appears to now be in /opt/homebrew/include. I know I might could symlink things but I would like to do this the proper way. How do I make platformio recognize this directory. I don’t remember having to do anything on Big Sur.

What is your shell? See

@ivankravets ,
I am also having issues with the simulator

I followed this page: GitHub - lvgl/lv_platformio: PlatformIO project example for LVGL

.pio/libdeps/emulator_64bits/lv_drivers/sdl/sdl.c:53:10: fatal error: 'SDL2/SDL.h' file not found
#include SDL_INCLUDE_PATH
         ^~~~~~~~~~~~~~~~
<command line>:12:26: note: expanded from here
#define SDL_INCLUDE_PATH "SDL2/SDL.h"
                         ^~~~~~~~~~~~

So if you did brew install sdl2, where are those files then? Can you cd / && sudo find . -name "SDL.h" ?

@maxgerhardt

 ~ % brew --prefix sdl2
/opt/homebrew/opt/sdl2

/opt/homebrew/Cellar/sdl2/2.26.3/include/SDL2/SDL.h

I update the platformio.ini to have the build flag like

  -D SDL_INCLUDE_PATH="\"/opt/homebrew/Cellar/sdl2/2.26.3/include/SDL2/SDL.h\""

The error became

hal/sdl2/app_hal.c:3:10: fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
         ^~~~~~~~~~~~
1 error generated.

Well sadly they but a hardcoded path in there. I think it’s better to just add /opt/homebrew/Cellar/sdl2/2.26.3/include/ to the include path though and let -D SDL_INCLUDE_PATH="\"SDL2/SDL.h\"" be.

So the only modification to the build flags you need to make is adding

   -I/opt/homebrew/Cellar/sdl2/2.26.3/include

@maxgerhardt ,

thanks. It progressed but failed here:

Linking .pio/build/emulator_64bits/program
ld: library not found for -lSDL2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
*** [.pio/build/emulator_64bits/program] Error 1

Does /opt/homebrew/Cellar/sdl2/2.26.3/ have a lib, bin or library folder where the libSDL.a file is? Add this folder to the library search path with a

   -L/opt/homebrew/Cellar/sdl2/2.26.3/lib

line in build_flags.

1 Like

@maxgerhardt ,

It work.

Tks a lot

I does not work so far on my Macbook Pro (M1 chip). Although it compiles now, but does not link, because the architecture (not x86 but arm64) is different. How did you solve the issue?

ld: warning: ignoring file /opt/homebrew/Cellar/sdl2/2.26.4/lib/libSDL2.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
“_SDL_CreateRenderer”, referenced from:
_window_create in sdl.o

Any help very appreciated.

I am on Macbook Pro M1 chip too but it worked with just adding

 -I /opt/homebrew/Cellar/sdl2/2.26.4/include
  -L /opt/homebrew/Cellar/sdl2/2.26.4/lib
2 Likes

That’s what I did for the Include and Link options.

ld: warning: ignoring file /opt/homebrew/Cellar/sdl2/2.26.4/lib/libSDL2.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64

It looks like VSC builds for x64_64 but not for arm64 (M1), where sdl2 is for arm64.

Checking gcc --version or clang --version reveals that both are building for Target: arm64-apple-darwin22.3.0.

I must have missed something.

Here are my build flags:
build_flags (Advanced->Verbose build): -D LV_CONF_SKIP, -D LV_CONF_INCLUDE_SIMPLE, -D LV_USE_DEMO_WIDGETS=1, -D LV_LOG_PRINTF=1, !python -c “import os; print(’ ‘.join([’-I {}‘.format(i[0].replace(’\x5C’,‘/’)) for i in os.walk(‘hal/sdl2’)]))”, -lSDL2, -L /opt/homebrew/Cellar/sdl2/2.26.4/lib, -I /opt/homebrew/Cellar/sdl2/2.26.4/include, -D SDL_INCLUDE_PATH=“"SDL2/SDL.h"”, -D LV_LVGL_H_INCLUDE_SIMPLE, -D LV_DRV_NO_CONF, -D USE_SDL, -D SDL_HOR_RES=480, -D SDL_VER_RES=320, -D SDL_ZOOM=1, -D SDL_INCLUDE_PATH=“"SDL2/SDL.h"”, -D LV_MEM_CUSTOM=1, -D LV_MEM_SIZE=“(128U * 1024U)”; lib_deps: lvgl=https://github.com/lvgl/lvgl/archive/refs/tags/v8.2.0.zip, lv_drivers=https://github.com/lvgl/lv_drivers/archive/refs/tags/v8.2.0.zip; build_src_filter: +<*>, +<…/hal/sdl2>, +<…/.pio/libdeps/emulator_64bits/lvgl/demos>; lib_archive: False)

Any hint to solve my issues are very welcome.

Finally, I figured out what happened. The root cause is the VSC platform extension. I am writing a new post to provide two ways to solve this problem: PlatformIO installed an x86_64 arch python in M chip mac.