lvgl / lv_web_emscripten

LVGL ported to Emscripten to be converted to JavaScript
MIT License
80 stars 28 forks source link

Build Error - Possible lvgl submodule version error #10

Closed PatrickGHall closed 3 years ago

PatrickGHall commented 3 years ago

Working on getting a project building with emscripten using this repo as a starting point, however I'm getting a build error on this repo. I'm running on Ubuntu 21.04 and already have libsdl2 and libsdl2-dev installed from the package manager.

Steps:

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ..
git clone https://github.com/lvgl/lv_sim_emscripten.git
git submodule update --init --recursive

Then, from the readme, it suggests you can run make or emconfigure cmake -DCMAKE_TOOLCHAIN_FILE="${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" -S . -B build && cmake --build build -j $(nproc)

make fails because there is no top-level makefile. The second command gives an error:

error: use `emcmake` rather then `emconfigure` for cmake projects

So, adjusting the command to:

emcmake cmake -DCMAKE_TOOLCHAIN_FILE="${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" -S . -B build && cmake --build build -j $(nproc)

starts a build, however it fails with:

lv_obj.c:304:12: error: use of undeclared identifier 'LV_BASE_DIR_AUTO'; did you mean 'LV_BIDI_DIR_AUTO'?
    return LV_BIDI_BASE_DIR_DEF;
           ^~~~~~~~~~~~~~~~~~~~
           LV_BIDI_DIR_AUTO
lv_conf.h:364:30: note: expanded from macro 'LV_BIDI_BASE_DIR_DEF'
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
                             ^
lv_bidi.h:36:5: note: 'LV_BIDI_DIR_AUTO' declared here
    LV_BIDI_DIR_AUTO     = 0x02,
    ^
1 error generated.

Editing the lv_conf.h file to alias this definition again #define LV_BASE_DIR_AUTO LV_BIDI_DIR_AUTO gets further along, but eventually fails with:

lv_sim_emscripten/lvgl/src/extra/widgets/span/lv_span.c:92:62: error: too many arguments to function call, expected 2, have 3
    return lv_obj_class_create_obj(&lv_spangroup_class, par, NULL);
           ~~~~~~~~~~~~~~~~~~~~~~~                           ^~~~
emsdk/upstream/emscripten/cache/sysroot/include/string.h:13:14: note: expanded from macro 'NULL'
#define NULL ((void*)0)
             ^~~~~~~~~~
lv_sim_emscripten/lvgl/src/extra/widgets/span/../../../../src/core/lv_obj_class.h:75:20: note: 'lv_obj_class_create_obj' declared here
struct _lv_obj_t * lv_obj_class_create_obj(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * parent);
                   ^
1 error generated.

Which leads me to believe there is something going wrong not on my end since these definitions don't line up. It's also possible I'm running the wrong commands since the README seems to be a little out of date. For example, the instructions for cloning the lv_sim_emscripten repo point to a different name but I haven't looked too much into that.

embeddedt commented 3 years ago

Thanks!

Please pull the latest version, update submodules, and follow the new steps in the README - it has been updated.