Skip to content

The demos do not compile on MacOS with Apple Silicon (ARM) CPU #193

Open
@SketchPiece

Description

@SketchPiece

Summary

I'm trying to run the demo examples of this project on my MacBook Pro (M1 Pro, macOS Sequoia 15.2) but encounter issues related to SDL2 during compilation, linking, and runtime. Despite following the setup instructions and troubleshooting extensively, I end up with a segmentation fault.

Could you help me identify what's missing in my setup or how to resolve this?

Environment:

  • Device: MacBook Pro (M1 Pro)
  • OS: macOS Sequoia 15.2
  • Toolchain:
    • Rust (stable version)
    • Homebrew-installed SDL2

Steps to Reproduce

Before running the demo examples I update all git submodules and as stated in the documentation and other issue #35 I install sdl2 for the simulator display to work properly on macOS

$ brew install sdl2
$ git submodule init
$ git submodule update 

When I'm trying to run the demo with the following command

$ DEP_LV_CONFIG_PATH=`pwd`/examples/include cargo run --example demo --features="alloc"

During the lvgl-sys compilation I'm getting an error that SDL2/SDL.h cannot be found

...
sys/vendor/lv_drivers/sdl/sdl_common_internal.h:21:10: fatal error: 'SDL2/SDL.h' file not found
warning: [email protected]:    21 | #include SDL_INCLUDE_PATH
warning: [email protected]:       |          ^~~~~~~~~~~~~~~~
warning: [email protected]: /Users/sketchpiece/Documents/Hacking/temp/lv_binding_rust/examples/include/lv_drv_conf.h:109:31: note: expanded from macro 'SDL_INCLUDE_PATH'
warning: [email protected]:   109 | #  define SDL_INCLUDE_PATH    <SDL2/SDL.h>
warning: [email protected]:       |                               ^~~~~~~~~~~~
warning: [email protected]: <scratch space>:498:1: note: expanded from here
warning: [email protected]:   498 | <SDL2/SDL.h>
warning: [email protected]:       | ^~~~~~~~~~~~
warning: [email protected]: 1 error generated.
...
error occurred in cc-rs: Command env -u IPHONEOS_DEPLOYMENT_TARGET LC_ALL="C" "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=arm64-apple-macosx15.2" "-I" "/Users/sketchpiece/Documents/Hacking/temp/lv_binding_rust/lvgl-sys/vendor/lvgl/src" "-I" "/Users/sketchpiece/Documents/Hacking/temp/lv_binding_rust/lvgl-sys/vendor" "-I" "/Users/sketchpiece/Documents/Hacking/temp/lv_binding_rust/examples/include" "-I" "/Users/sketchpiece/Documents/Hacking/temp/lv_binding_rust/fonts" "-I" "/Users/sketchpiece/Documents/Hacking/temp/lv_binding_rust/lvgl-sys/vendor/lv_drivers" "-I" "/usr/include" "-I" "/usr/local/include" "-DLV_CONF_INCLUDE_SIMPLE=1" "-o" "/Users/sketchpiece/Documents/Hacking/temp/lv_binding_rust/target/debug/build/lvgl-sys-1fba6286d2a9502f/out/5dda4e2b23dfaa0a-sdl_common.o" "-c" "/Users/sketchpiece/Documents/Hacking/temp/lv_binding_rust/lvgl-sys/vendor/lv_drivers/sdl/sdl_common.c" with args cc did not execute successfully (status code exit status: 1).

Full output

I noticed that during compilation no include libraries from brew were added which were moved from /usr/include to /opt/homebrew/lib for the arm macOS
And I tried adding this folder with LVGL_INCLUDE.

$ DEP_LV_CONFIG_PATH=`pwd`/examples/include LVGL_INCLUDE="/usr/include,/usr/local/include,/opt/homebrew/include" cargo run --example demo --features="alloc"

But I was getting yet another error regarding linux frame buffer

...
sys/vendor/lv_drivers/display/fbdev.c:26:10: fatal error: 'linux/fb.h' file not found
warning: [email protected]:    26 | #include <linux/fb.h>
warning: [email protected]:       |          ^~~~~~~~~~~~
warning: [email protected]: 1 error generated.
...

Full output

I changed USE_FBDEV in the lv_drv_conf.h to 0

/*-----------------------------------------
 *  Linux frame buffer device (/dev/fbx)
 *-----------------------------------------*/
#ifndef USE_FBDEV
#  define USE_FBDEV           0 // was 1 before
#endif

After running the same command with brew include paths I was still getting now linker errors regarding SDL2

 = note: ld: library 'SDL2' not found
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

I was able to resolve the linker error by exporting explicitly to the linker and cpp compiler the location of the lib and include folders

$ export LDFLAGS="-L/opt/homebrew/lib"
$ export CPPFLAGS="-I/opt/homebrew/include"
$ export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"

But eventually I was still getting seg fault

warning: `lvgl` (example "demo") generated 4 warnings (run `cargo fix --example "demo"` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running `target/debug/examples/demo`
[1]    29339 segmentation fault  DEP_LV_CONFIG_PATH=`pwd`/examples/include LVGL_INCLUDE= cargo run --example

I would be happy to know what could be done to solve this issue and compile demo example on the mac. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions