Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SketchPiece opened this issue Jan 15, 2025 · 4 comments
Open

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

SketchPiece opened this issue Jan 15, 2025 · 4 comments

Comments

@SketchPiece
Copy link

SketchPiece commented Jan 15, 2025

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!

@C47D
Copy link
Collaborator

C47D commented Jan 17, 2025

Hi, just to let you know that I've read the issue and it's been added to a list of TODO items. I don't own a Mac and it might be a bit difficult for me to try replicate, but I'll try.

@C47D C47D mentioned this issue Jan 14, 2025
11 tasks
@SketchPiece
Copy link
Author

@C47D Maybe something I could help you with or some more info I could provide?

@AlixANNERAUD
Copy link
Collaborator

Can you run it with valgrind and provide us the dump here ?

@SketchPiece
Copy link
Author

It looks like valgrind is not currently compatible with mac

https://www.reddit.com/r/cs50/comments/meq16w/how_to_get_valgrind_on_macos/

When I try to install valgrind executables it throws with following error:

➜  ~ brew install valgrind

...

valgrind: Linux is required for this software.
Error: valgrind: An unsatisfied requirement failed this build.

Do you know any other software that could help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants