lvgl / lv_binding_micropython

LVGL binding for MicroPython
MIT License
237 stars 156 forks source link

Error when building the JS port locally #190

Closed kisvegabor closed 2 years ago

kisvegabor commented 2 years ago

Hi,

I'm trying to build the JS port locally. I followed the steps from this action. All looks good except make -j8 -C ports/javascript` gives this error:

$  make -j8 -C ports/javascript
make: Entering directory '/home/kisvegabor/projects/littlevgl/edgeline/web/lv_micropython/ports/javascript'
************  lvgl_javascript version ************
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Warning: FROZEN_DIR is deprecated in favour of FROZEN_MANIFEST
LVGL-GEN build/lvgl/lv_mpy.c
LODEPNG-GEN build/lodepng/mp_lodepng.c
error: invalid argument '-std=c++03' not allowed with 'C'
../../py/py.mk:44: recipe for target 'build/lvgl/lv_mpy.c' failed
make: *** [build/lvgl/lv_mpy.c] Error 1
make: *** Waiting for unfinished jobs....
error: invalid argument '-std=c++03' not allowed with 'C'
../../py/py.mk:69: recipe for target 'build/lodepng/mp_lodepng.c' failed
make: *** [build/lodepng/mp_lodepng.c] Error 1
make: Leaving directory '/home/kisvegabor/projects/littlevgl/edgeline/web/lv_micropython/ports/javascript'

Do you have any idea what could be wrong?

embeddedt commented 2 years ago

I don't think we reference -std=c++03 in the Micropython repository at all. Is it possible that you have a global environment variable set like CXXFLAGS/CFLAGS which contains this?

kisvegabor commented 2 years ago

I grepd for std=c++03 in the whole lv_micropython project but I couldn't find any references either.

Both echo $CXXFLAGS and echo $CFLAGS returns nothing.

Maybe something is messed up on my machine but I tried to built the Eclipse SDL project with make and it worked.

Interestingly the error shown for lv_mpy.c and mp_lodepng.c that are related to LVGL.

amirgon commented 2 years ago

Interestingly the error shown for lv_mpy.c and mp_lodepng.c that are related to LVGL.

Maybe because these are the first files being compiled?

Did you try upstream Micropython without LVGL?
Did you try make V=1 to get more logs from Make?
Try to print all environment variables before running "make" and grep c++03

kisvegabor commented 2 years ago

Did you try upstream Micropython without LVGL?

Yes, and got a different error:

python3 ../../py/makeversionhdr.py build/genhdr/mpversion.h
GEN build/genhdr/qstrdefs.generated.h
cat ../../py/qstrdefs.h qstrdefsport.h build/genhdr/qstrdefs.collected.h | sed 's/^Q(.*)/"&"/' | emcc -E -std=c99 -Wall -Werror -Wdouble-promotion -Wfloat-conversion -O3 -DNDEBUG -I. -I../.. -Ibuild - | sed 's/^\"\(Q(.*)\)\"/\1/' > build/genhdr/qstrdefs.preprocessed.h
shared:ERROR: no input files
note that input files without a known suffix are ignored, make sure your input files end with one of: ('.c', '.C', '.i', '.cpp', '.cxx', '.cc', '.c++', '.CPP', '.CXX', '.CC', '.C++', '.ii', '.m', '.mi', '.mm', '.mii', '/dev/null', '.bc', '.o', '.obj', '.lo', '.dylib', '.so', '.a', '.ll', '.h', '.hxx', '.hpp', '.hh', '.H', '.HXX', '.HPP', '.HH')
python3 ../../py/makeqstrdata.py build/genhdr/qstrdefs.preprocessed.h > build/genhdr/qstrdefs.generated.h
ERROR: Empty preprocessor output - check for errors above
../../py/py.mk:262: recipe for target 'build/genhdr/qstrdefs.generated.h' failed
make: *** [build/genhdr/qstrdefs.generated.h] Error 1
make: *** Deleting file 'build/genhdr/qstrdefs.generated.h'

Did you try make V=1 to get more logs from Make?

Yes, but nothing special:

************  lvgl_javascript version ************
Warning: FROZEN_DIR is deprecated in favour of FROZEN_MANIFEST
LVGL-GEN build/lvgl/lv_mpy.c
mkdir -p build/lvgl/
LODEPNG-GEN build/lodepng/mp_lodepng.c
emcc -x c -E -D__CPP__ -D__EMSCRIPTEN__  -DPYCPARSER -x c -I ../../lib/lv_bindings/pycparser/utils/fake_libc_include -I../../lib/lv_bindings -I../../lib/lv_bindings/driver/png/lodepng -I. -I../.. -Ibuild ../../lib/lv_bindings/lvgl/lvgl.h > build/lvgl/lvgl.pp.c
mkdir -p build/lodepng/
python3 ../../py/makeversionhdr.py build/genhdr/mpversion.h
emcc -x c -E -D__CPP__ -D__EMSCRIPTEN__ -DLODEPNG_NO_COMPILE_ENCODER -DLODEPNG_NO_COMPILE_DISK -DLODEPNG_NO_COMPILE_ALLOCATORS -DPYCPARSER -x c -I../../lib/lv_bindings -I../../lib/lv_bindings/driver/png/lodepng -I. -I../.. -Ibuild -I ../../lib/lv_bindings/pycparser/utils/fake_libc_include ../../lib/lv_bindings/driver/png/lodepng/lodepng.h > build/lodepng/lodepng.pp.c
error: invalid argument '-std=c++03' not allowed with 'C'
../../py/py.mk:44: recipe for target 'build/lvgl/lv_mpy.c' failed
make: *** [build/lvgl/lv_mpy.c] Error 1
make: *** Waiting for unfinished jobs....
error: invalid argument '-std=c++03' not allowed with 'C'
../../py/py.mk:69: recipe for target 'build/lodepng/mp_lodepng.c' failed
make: *** [build/lodepng/mp_lodepng.c] Error 1

Try to print all environment variables before running "make" and grep c++03

printenv | grep 03 returns nothing.


I also grepd for this string in my whole home folder but found only a few matches in platformio folders.

embeddedt commented 2 years ago

-std=c++03 isn't showing up in the make V=1 output, so I'm assuming it must be getting added by your Emscripten installation itself, not Micropython.

Which version are you using? (I use 2.0.4.)

If it's not installed system-wide you could download a fresh emsdk to a new folder and try that.

kisvegabor commented 2 years ago

I've updated to the latest emsdk the problem is solved! Thanks you very much!

But... Now all files are built but fails on linking. I needed to modify the Makefile to add SDL.

CC ../../lib/lv_bindings/lvgl/examples/layouts/flex/lv_example_flex_6.c
CC ../../lib/lv_bindings/lvgl/examples/others/snapshot/lv_example_snapshot_1.c
CC build/lvgl/lv_mpy.c
CC build/lodepng/lodepng.c
CC ../../lib/lv_bindings/driver/png/mp_lodepng.c
CC build/lodepng/mp_lodepng.c
CC ../../lib/lv_bindings/driver/SDL/SDL_monitor.c
CC ../../lib/lv_bindings/driver/SDL/SDL_mouse.c
CC ../../lib/lv_bindings/driver/SDL/modSDL.c
LINK build/firmware.js
wasm-ld: error: build/py/objmodule.o: undefined symbol: mp_module_lvindev
emcc: error: '/home/kisvegabor/projects/littlevgl/emsdk/upstream/bin/wasm-ld @/tmp/emscripten_o7qgbcji.rsp' failed (returned 1)
Makefile:96: recipe for target 'build/micropython.js' failed
make: *** [build/micropython.js] Error 1
embeddedt commented 2 years ago

I needed to modify the Makefile to add SDL.

Hmm, what do you mean? As far as I know it should be added by this line.

(You may have to run embuilder build sdl2 once manually on a fresh SDK.)

kisvegabor commented 2 years ago

Hmm, what do you mean? As far as I know it should be added by this line.

Probably, I needed those tweaks due to the missed embuilder call.

Now I get to the linking stage with the untouched Makefile but got the same error on linking. I'm using the latest emsdk (2.0.31)

If use emsdk 1.38.31 as suggested here make immediately fails with "no input files" error.

embeddedt commented 2 years ago

I will try 2.0.31 later and see if I can get the same error.

kisvegabor commented 2 years ago

Thank you very much.

I've also tried to install 2.0.4 as you mentioned but

$ emsdk install fastcomp-clang-e2.0.4-64bit
error: tool or SDK not found: 'fastcomp-clang-e2.0.4-64bit'
embeddedt commented 2 years ago

I'm almost certain I had updated the installation instructions, but they seem to still mention 1.38.31. Maybe they were lost in a merge conflict... :confused:

Fastcomp doesn't exist anymore. I think these on their own should be enough:

./emsdk install 2.0.4
./emsdk activate 2.0.4
kisvegabor commented 2 years ago

WOOOORKIIING! :slightly_smiling_face:

I could install/activate 2.0.4 as you suggested, and now it linked.

Thank you very much! I don't know how could I solve it without your help :slightly_smiling_face:

embeddedt commented 2 years ago

Great! I'll see if I can fix the issue with 2.0.31 so we're not pinned to an ancient version for a year again.