strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build error file not found

SGCBB opened this issue · comments

Not sure why but I can't get it to buildjs using the emscripten script from source or from 1.17.6 per the readme.

[ 75%] Building CXX object libheif/CMakeFiles/heif.dir/plugins/encoder_mask.cc.o
cd /home/user/libheif/buildjs/libheif && /usr/bin/em++ -DHAVE_LIBDE265=1 -DHAVE_VISIBILITY -DLIBHEIF_EXPORTS @CMakeFiles/heif.dir/includes_CXX.rsp -O3 -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden   -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -Wno-error=unused-parameter -Wno-error=deprecated-declarations -Wno-error=tautological-compare -Wno-error=tautological-constant-out-of-range-compare -std=c++11 -MD -MT libheif/CMakeFiles/heif.dir/plugins/encoder_mask.cc.o -MF CMakeFiles/heif.dir/plugins/encoder_mask.cc.o.d -o CMakeFiles/heif.dir/plugins/encoder_mask.cc.o -c /home/user/libheif/libheif/plugins/encoder_mask.cc
/home/user/libheif/libheif/plugins/decoder_libde265.cc:30:10: fatal error: 'libde265/de265.h' file not found
#include <libde265/de265.h>
         ^~~~~~~~~~~~~~~~~~
1 error generated.
em++: error: '/usr/bin/clang++-13 -target wasm32-unknown-emscripten -DEMSCRIPTEN -D__EMSCRIPTEN_major__=3 -D__EMSCRIPTEN_minor__=1 -D__EMSCRIPTEN_tiny__=5 -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D_LIBCPP_ABI_VERSION=2 -fno-threadsafe-statics -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=/usr/share/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -DHAVE_LIBDE265=1 -DHAVE_VISIBILITY -DLIBHEIF_EXPORTS -I/home/user/libheif/buildjs -I/home/user/libheif -I/home/user/libheif/include/libheif -I/home/user/libheif/include -I/home/user/libheif/libde265-1.0.12 -O3 -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -Wno-error=unused-parameter -Wno-error=deprecated-declarations -Wno-error=tautological-compare -Wno-error=tautological-constant-out-of-range-compare -std=c++11 -MD -MT libheif/CMakeFiles/heif.dir/plugins/decoder_libde265.cc.o -MF CMakeFiles/heif.dir/plugins/decoder_libde265.cc.o.d -c /home/user/libheif/libheif/plugins/decoder_libde265.cc -o CMakeFiles/heif.dir/plugins/decoder_libde265.cc.o' failed (returned 1)
make[2]: *** [libheif/CMakeFiles/heif.dir/build.make:542: libheif/CMakeFiles/heif.dir/plugins/decoder_libde265.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/user/libheif/buildjs'
make[1]: *** [CMakeFiles/Makefile2:989: libheif/CMakeFiles/heif.dir/all] Error 2
make[1]: Leaving directory '/home/user/libheif/buildjs'
make: *** [Makefile:166: all] Error 2
emmake: error: 'make -j8' failed (returned 2)

Have you built de265? A bit more context might help us to help you - configuration, steps, fault finding / debugging you've already done could all be helpful.

Ok, well I got it to compile without errors.. finally :D

I'm not going to attempt to push anything right now as I had to make a few static changes, let the compile fail and then alter things to get it to work on the second build attempt. I'll try to find time to test and contribute my findings (once I figure out what exactly they are).

I'll reproduce what I did to explain, here it goes...

I stuck with the Pi and to get it to compile for my Raspberry Pi I added --host=x86_64 to ./configure to build-emscripten.sh on Line 45:
CXXFLAGS=-O3 emconfigure ./configure --host=x86_64 --enable-static --disable-shared --disable-sse --disable-dec265 --disable-sherlock265

Changed the variable DLIBDE265_LIBRARY in build-emscripten.sh on Line 49 to be static:
CONFIGURE_ARGS_LIBDE265="-DLIBDE265_INCLUDE_DIR=${DIR}/libde265-${LIBDE265_VERSION} -DLIBDE265_LIBRARY=-L/home/rpi/libheif/buildjs/libde265-1.0.12/libde265/.libs"

Statically referenced the location of llvm-nm in build-emscripten.sh on Line 107:
EXPORTED_FUNCTIONS=$(/usr/lib/llvm-14/bin/llvm-nm $LIBHEIFA --format=just-symbols | grep "^heif_\|^de265_\|^aom_" | grep "[^:]$" | sed 's/^/_/' | paste -sd "," -)

Extended LIBRARY_LINKER_FLAGS to statically point to the path of (-lde265) libde265 in build-emscripten.sh on the empty Line 124:
LIBRARY_LINKER_FLAGS="$LIBRARY_LINKER_FLAGS -L/home/rpi/libheif/buildjs/libde265-1.0.12/libde265/.libs -lde265"

Alter the include to be static for #include <libde265/de265.h> on Line 30 to:
#include </home/rpi/libheif/buildjs/libde265-1.0.12/libde265/de265.h>

Build from the subdirectory buildjs with USE_WASM=0 ../build-emscripten.sh .. and let it fail at 75%. Then modify [Line 29] of this file /home/rpi/libheif/buildjs/libde265-1.0.12/libde265/de265.h from #include <libde265/de265-version.h> to:
#include "de265-version.h"

Build again with USE_WASM=0 ../build-emscripten.sh .. and it works.. Also tested with USE_WASM=1 as well and it provided both files.

It's probably just me, but my attempting to follow the javascript compile guide failed (even after attempting to apt install every *-dev I could find to be relevant). I've tried the javascript I compiled with my previous integration code from v1.12.0 and everything feels correct and appears to be working without issue (however I decided to add window.libheif = new libheif; to the end of libheif.js to correct loading consistently between refreshes and even the demo page reproduces inconsistencies across refreshing, execution timing/delays maybe even the browser?).