Zephyr 有个非常棒的功能叫做Native SIM,就是把zephyr build 成一个linux上的可执行文件跑,这样的话调试跟UI相关应用就会非常的方便。
1.先挑选一个LVGL的demo,在sample/modules/lvgl/demos这个目录,我匆匆看了下readme,就开搞。
1 | west build -p always -b native_sim samples/modules/lvgl/demos |
2.不出所料build不过,提示找不到这个目录
1 | /usr/include/SDL2/SDL_config.h:4:10: fatal error: SDL2/_real_SDL_config.h: No such file or directory |
3.于是我在linux搜索,我还真的找到了这个文件1
2admin@6vbapldvahorygh:/bin$ sudo find / -name "_real_SDL_config.h" 2>/dev/null
/usr/include/x86_64-linux-gnu/SDL2/_real_SDL_config.h
4.那我把这个文件加到CMAKE1
include_directories(/usr/include/x86_64-linux-gnu/SDL2)
5.还是过不了,提示不兼容和找不到lib,这里百思不得其解,找Deepseek帮忙搜了半天,指定lib文件名等各种操作,还是这个error,有点崩溃,一上午就这样没了。1
2
3
4
5/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL2.so when searching for -lSDL2
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL2.a when searching for -lSDL2
/usr/bin/ld: skipping incompatible /usr/local/lib/libSDL2.so when searching for -lSDL2
/usr/bin/ld: skipping incompatible /usr/local/lib/libSDL2.a when searching for -lSDL2
/usr/bin/ld: cannot find -lSDL2
6.吃完午饭,我把readme 拿出来想看下是否还有其他线索,我看到了最重要的一条。1
2Alternatively, if building from a 64-bit host machine, the previous target
board argument may also be replaced by ``native_sim/native/64``.
7.于是我回到第一步,修改build command,把 native_sim 改成 native_sim/native/641
west build -p always -b native_sim/native/64 samples/modules/lvgl/demos
8.跳到 build/zephyr目录,执行 zephyr.exe,于是看到了激动人心的 demo app UI,真是漂亮啊。自己为什么就不能一开始就把readme看完呢?