melchor629 / node-flac-bindings

Nodejs bindings to libFLAC
ISC License
17 stars 1 forks source link

Installation fails on Android #23

Closed shahriar-shojib closed 3 years ago

shahriar-shojib commented 3 years ago

Hello, I am trying to install flac-bindings on android with termux.

$ uname -a
> Linux localhost 4.9.186-perf-g344bf82 #1 SMP PREEMPT Thu Jun 11 00:40:19 CST 2020 aarch64 Android

First of all, I can see that there are prebuilts for amd64 but for some reason, it tries to compile it. And when compiling , it fails with the following message:

$ yarn add flac-bindings
yarn add v1.22.10
info No lockfile found.
[1/4] Resolving packages...
warning flac-bindings > cmake-js > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning flac-bindings > cmake-js > request > har-validator@5.1.5: this library is no longer supported
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error /data/data/com.termux/files/home/test/node_modules/flac-bindings: Command failed.
Exit code: 1
Command: node scripts/flac-build.js
Arguments:
Directory: /data/data/com.termux/files/home/test/node_modules/flac-bindings
Output:
> prebuild-install -r napi
prebuild-install WARN install No prebuilt binaries found (target=6 runtime=napi arch=arm64 libc= platform=android)
> which brew >/dev/null 2>&1 && eval $(brew --env) && echo $PKG_CONFIG_LIBDIR
> PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config --modversion flac
> cmake-js build
[
  '/data/data/com.termux/files/usr/bin/node',
  '/data/data/com.termux/files/home/test/node_modules/flac-bindings/node_modules/.bin/cmake-js',
  'build'
]
info TOOL Using Unix Makefiles generator.
info CMD CONFIGURE
info RUN cmake "/data/data/com.termux/files/home/test/node_modules/flac-bindings" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="6.1.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/data/data/com.termux/files/home/test/node_modules/flac-bindings/build/Release" -DCMAKE_JS_INC="/data/data/com.termux/files/home/.cmake-js/node-arm64/v14.8.0/include/node" -DCMAKE_JS_SRC="" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="14.8.0" -DNODE_ARCH="arm64"
Not searching for unused variables given on the command line.
-- The C compiler identification is Clang 10.0.1
-- The CXX compiler identification is Clang 10.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /data/data/com.termux/files/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /data/data/com.termux/files/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring libogg 1.3.4
-- Looking for include file inttypes.h
-- Looking for include file inttypes.h - found
-- Looking for include file stdint.h
-- Looking for include file stdint.h - found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of int16_t
-- Check size of int16_t - done
-- Check size of uint16_t
-- Check size of uint16_t - done
-- Check size of u_int16_t
-- Check size of u_int16_t - done
-- Check size of int32_t
-- Check size of int32_t - done
-- Check size of uint32_t
-- Check size of uint32_t - done
-- Check size of u_int32_t
-- Check size of u_int32_t - done
-- Check size of int64_t
-- Check size of int64_t - done
-- Check size of short
-- Check size of short - done
-- Check size of int
-- Check size of int - done
-- Check size of long
-- Check size of long - done
-- Check size of long long
-- Check size of long long - done
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Failed
-- Found Iconv: /data/data/com.termux/files/usr/lib/libiconv.so
-- Performing Test DODEFINE_FORTIFY_SOURCE
-- Performing Test DODEFINE_FORTIFY_SOURCE - Success
-- Performing Test HAVE_MBSTATE
-- Performing Test HAVE_MBSTATE - Success
-- Performing Test DODEFINE_EXTENSIONS
-- Performing Test DODEFINE_EXTENSIONS - Success
-- Looking for byteswap.h
-- Looking for byteswap.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for x86intrin.h
-- Looking for x86intrin.h - not found
-- Looking for fseeko
-- Looking for fseeko - found
-- Performing Test HAVE_BSWAP16
-- Performing Test HAVE_BSWAP16 - Success
-- Performing Test HAVE_BSWAP32
-- Performing Test HAVE_BSWAP32 - Success
-- Check if the system is big endian
-- Searching 16 bit integer
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Searching 16 bit integer - Using unsigned short
-- Check if the system is big endian - little endian
-- Performing Test HAVE_WERROR_FLAG
-- Performing Test HAVE_WERROR_FLAG - Success
-- Performing Test HAVE_DECL_AFTER_STMT_FLAG
-- Performing Test HAVE_DECL_AFTER_STMT_FLAG - Success
-- Performing Test HAVE_STACKREALIGN_FLAG
-- Performing Test HAVE_STACKREALIGN_FLAG - Success
-- Performing Test HAVE_WEFFCXX_FLAG
-- Performing Test HAVE_WEFFCXX_FLAG - Success
-- Performing Test HAVE_STACK_PROTECTOR_FLAG
-- Performing Test HAVE_STACK_PROTECTOR_FLAG - Success
-- Looking for cpuid.h
-- Looking for cpuid.h - not found
-- Looking for sys/param.h
-- Looking for sys/param.h - found
-- Looking for lround
-- Looking for lround - found
-- Check CPU architecture is x64
-- Check CPU architecture is x64 - no
-- Check CPU architecture is x86
-- Check CPU architecture is x86 - no
-- Looking for a ASM_NASM compiler
-- Looking for a ASM_NASM compiler - NOTFOUND
-- Looking for string.h
-- Looking for string.h - found
-- Found Intl: /data/data/com.termux/files/usr/include
-- Looking for clock_gettime
-- Looking for clock_gettime - found
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Configuring done
-- Generating done
-- Build files have been written to: /data/data/com.termux/files/home/test/node_modules/flac-bindings/build
info CMD BUILD
info RUN cmake --build "/data/data/com.termux/files/home/test/node_modules/flac-bindings/build" --config Release
Scanning dependencies of target ogg
[  1%] Building C object _deps/ogg-build/CMakeFiles/ogg.dir/src/bitwise.c.o
[  2%] Building C object _deps/ogg-build/CMakeFiles/ogg.dir/src/framing.c.o
[  3%] Linking C static library libogg.a
[  3%] Built target ogg
Scanning dependencies of target FLAC
[  4%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/bitmath.c.o
[  6%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/bitreader.c.o
[  7%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/bitwriter.c.o
[  8%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/cpu.c.o
[  9%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/crc.c.o
[ 10%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/fixed.c.o
[ 12%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/fixed_intrin_sse2.c.o
[ 13%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/fixed_intrin_ssse3.c.o
[ 14%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/float.c.o
[ 15%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/format.c.o
[ 16%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/lpc.c.o
[ 18%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/lpc_intrin_sse.c.o
[ 19%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/lpc_intrin_sse2.c.o
[ 20%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/lpc_intrin_sse41.c.o
[ 21%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/lpc_intrin_avx2.c.o
[ 22%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/lpc_intrin_vsx.c.o
[ 24%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/md5.c.o
[ 25%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/memory.c.o
[ 26%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/metadata_iterators.c.o
[ 27%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/metadata_object.c.o
[ 28%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/stream_decoder.c.o
[ 30%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/stream_encoder.c.o
[ 31%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/stream_encoder_intrin_sse2.c.o
[ 32%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/stream_encoder_intrin_ssse3.c.o
[ 33%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/stream_encoder_intrin_avx2.c.o
[ 34%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/stream_encoder_framing.c.o
[ 36%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/window.c.o
[ 37%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/ogg_decoder_aspect.c.o
[ 38%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/ogg_encoder_aspect.c.o
[ 39%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/ogg_helper.c.o
[ 40%] Building C object _deps/flac-build/src/libFLAC/CMakeFiles/FLAC.dir/ogg_mapping.c.o
[ 42%] Linking C static library libFLAC.a
[ 42%] Built target FLAC
Scanning dependencies of target flac-bindings
[ 43%] Building CXX object CMakeFiles/flac-bindings.dir/src/decoder/async-decoder.cpp.o
[ 44%] Building CXX object CMakeFiles/flac-bindings.dir/src/decoder/decoder.cpp.o
[ 45%] Building CXX object CMakeFiles/flac-bindings.dir/src/encoder/async-encoder.cpp.o
[ 46%] Building CXX object CMakeFiles/flac-bindings.dir/src/encoder/encoder.cpp.o
[ 48%] Building CXX object CMakeFiles/flac-bindings.dir/src/format/format.cpp.o
[ 49%] Building CXX object CMakeFiles/flac-bindings.dir/src/index.cpp.o
[ 50%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/frame.cpp.o
[ 51%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/native_iterator.cpp.o
[ 53%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata.cpp.o
[ 54%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_application.cpp.o
[ 55%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_cuesheet.cpp.o
[ 56%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_cuesheet_index.cpp.o
[ 57%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_cuesheet_track.cpp.o
[ 59%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_padding.cpp.o
[ 60%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_picture.cpp.o
[ 61%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_seekpoint.cpp.o
[ 62%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_seektable.cpp.o
[ 63%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_streaminfo.cpp.o
[ 65%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_unknown.cpp.o
[ 66%] Building CXX object CMakeFiles/flac-bindings.dir/src/mappings/streammetadata_vorbiscomment.cpp.o
[ 67%] Building CXX object CMakeFiles/flac-bindings.dir/src/metadata/async-io-metadata2.cpp.o
[ 68%] Building CXX object CMakeFiles/flac-bindings.dir/src/metadata/metadata0.cpp.o
[ 69%] Building CXX object CMakeFiles/flac-bindings.dir/src/metadata/metadata1.cpp.o
[ 71%] Building CXX object CMakeFiles/flac-bindings.dir/src/metadata/metadata2.cpp.o
[ 72%] Building CXX object CMakeFiles/flac-bindings.dir/src/test_async.cpp.o
[ 73%] Linking CXX shared library Release/flac-bindings.node
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: _deps/flac-build/src/libFLAC/libFLAC.a(stream_decoder.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `FLAC__StreamDecoderStateString' which may bind externally can not be used when making a shared object; recompile with -fPIC
_deps/flac-build/src/libFLAC/libFLAC.a(stream_decoder.c.o): in function `FLAC__stream_decoder_get_resolved_state_string':
stream_decoder.c:(.text+0x10c0): dangerous relocation: unsupported relocation
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: _deps/flac-build/src/libFLAC/libFLAC.a(stream_encoder.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `FLAC__StreamEncoderStateString' which may bind externally can not be used when making a shared object; recompile with -fPIC
_deps/flac-build/src/libFLAC/libFLAC.a(stream_encoder.c.o): in function `FLAC__stream_encoder_get_resolved_state_string':
stream_encoder.c:(.text+0x3bd8): dangerous relocation: unsupported relocation
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: _deps/flac-build/src/libFLAC/libFLAC.a(crc.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `FLAC__crc8_table' which may bind externally can not be used when making a shared object; recompile with -fPIC
_deps/flac-build/src/libFLAC/libFLAC.a(crc.c.o): in function `FLAC__crc8':
crc.c:(.text+0x8): dangerous relocation: unsupported relocation
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: _deps/flac-build/src/libFLAC/libFLAC.a(crc.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `FLAC__crc16_table' which may bind externally can not be used when making a shared object; recompile with -fPIC
_deps/flac-build/src/libFLAC/libFLAC.a(crc.c.o): in function `FLAC__crc16':
crc.c:(.text+0x40): dangerous relocation: unsupported relocation
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: _deps/flac-build/src/libFLAC/libFLAC.a(crc.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `FLAC__crc16_table' which may bind externally can not be used when making a shared object; recompile with -fPIC
crc.c:(.text+0xf4): dangerous relocation: unsupported relocation
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: _deps/flac-build/src/libFLAC/libFLAC.a(crc.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `FLAC__crc16_table' which may bind externally can not be used when making a shared object; recompile with -fPIC
_deps/flac-build/src/libFLAC/libFLAC.a(crc.c.o): in function `FLAC__crc16_update_words32':
crc.c:(.text+0x120): dangerous relocation: unsupported relocation
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: _deps/flac-build/src/libFLAC/libFLAC.a(crc.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `FLAC__crc16_table' which may bind externally can not be used when making a shared object; recompile with -fPIC
_deps/flac-build/src/libFLAC/libFLAC.a(crc.c.o): in function `FLAC__crc16_update_words64':
crc.c:(.text+0x228): dangerous relocation: unsupported relocation
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/flac-bindings.dir/build.make:465: Release/flac-bindings.node] Error 1
make[1]: *** [CMakeFiles/Makefile2:320: CMakeFiles/flac-bindings.dir/all] Error 2
make: *** [Makefile:171: all] Error 2
ERR! OMG Process terminated: 2

I think I also installed all the dependencies correctly as well. Please advise.

melchor629 commented 3 years ago

Hi, sorry the delay, been outside all weekend.

Well, never thought somebody wanted to use this on android... This issue is fixed for Linux, but the fix seems to not apply to Android specifically, for some reason. I will try to debug on my phone directly and come back here with what I will find.

Thanks for raising the issue :)

A btw, in the meantime try to install libflac. The node library should detect an already existing libFLAC and use that instead (but I did not tested this, so it may fail)

melchor629 commented 3 years ago

Hi again. I've been testing a bit on my phone and installing libflac seems to "fix" the issue (not exactly but it should work for your case). Also found why the installation failed and made a fix for Android when the phone does not have libflac installed (your scenario I guess). Right now I cannot create a new release, so if it is ok for you to install libflac on termux and give it a try...

First of all, I can see that there are prebuilts for amd64 but for some reason, it tries to compile it.

Let me explain: AMD64 is for desktops in general, smartphones uses aarch64 (see you uname -a) architecture which is ARM v8 64-bit. I also have aarch64 prebuild images for Linux but not for Android, so everything must be compiled for smartphones. As mentioned before, if you install libflac before this package, the compilation time will reduce because it will not need to compile libflac, only this package's code (which also takes some time).

shahriar-shojib commented 3 years ago

I am pretty sure I had libflac and cmake installed beforehand, I'll check again. Thanks for the update.

melchor629 commented 3 years ago

Hi again, any update on this? Have you managed to install it?