Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build fail for android on linux #3107

Closed
sunjin1233 opened this issue Mar 7, 2019 · 16 comments
Closed

build fail for android on linux #3107

sunjin1233 opened this issue Mar 7, 2019 · 16 comments

Comments

@sunjin1233
Copy link

I want to use openh264 with ffmpeg for android app. I tried to build openh264 for android by below command.
make OS=android NDKROOT=~/Android/android-ndk-r18b TARGET=android-28 NDKLEVEL=28

but I failed with this error message.
ysroot=/home/cheolhwi/Android/android-ndk-r18b/platforms/android-28/arch-arm -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -Wl,-soname,libopenh264.so
/usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux elf_l1om elf_k1om i386pep i386pe
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:240: recipe for target 'libopenh264.so' failed
make: *** [libopenh264.so] Error 1

I think that it failed by usage of wrong ld(/usr/bin/ld). Is it right? Please help me if someone has any idea.

@sunjin1233
Copy link
Author

My PATH = /home/cheolhwi/Android/android-ndk-r18b:/home/cheolhwi/Android/Sdk/tools:/home/cheolhwi/Android/Sdk/platform-tools:/home/cheolhwi/android-studio/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Ubuntu version is Ubuntu 18.04.2 LTS 64-bit

@Allen1207
Copy link

I just encountered almost the same problem, when I run: "make OS=android NDKROOT=/Users/allen/android-ndk-r18b TARGET=android-24 ARCH=arm NDKLEVEL=24"

ld: unknown option: --sysroot=/Users/allen/android-ndk-r18b/platforms/android-24/arch-arm
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

my system is MacOS

@GuangweiWang
Copy link
Collaborator

after NDK 17, android-ndk use clang as the default compiler and GCC is no longer supported. you can add this "NDK_TOOLCHAIN_VERSION=clang" to your command line for compiling openh264.

@sunjin1233 please try this:
e.g. make OS=android NDKROOT=~/Android/android-ndk-r18b TARGET=android-28 NDKLEVEL=28 NDK_TOOLCHAIN_VERSION=clang

@Allen1207 please try this:
make OS=android NDKROOT=/Users/allen/android-ndk-r18b TARGET=android-24 ARCH=arm NDKLEVEL=24 NDK_TOOLCHAIN_VERSION=clang

Please let me know if you have any questions.

@Allen1207
Copy link

hi @GuangweiWang ,

Thank you for your reply, but I got the same error as before when I add "NDK_TOOLCHAIN_VERSION=clang" to my command line.

@GuangweiWang
Copy link
Collaborator

@Allen1207
what about after clean ?
make OS=android NDKROOT=/Users/allen/android-ndk-r18b TARGET=android-24 ARCH=arm NDKLEVEL=24 NDK_TOOLCHAIN_VERSION=clang clean

@Allen1207
Copy link

Allen1207 commented Mar 8, 2019

@GuangweiWang , yes, I did add the clean, but the results still the same.
now I downloaded the android-ndk-r17c version, that error disappeared. But I got new errors:

/Users/allen/android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_so.o: No such file or directory
/Users/allen/android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtend_so.o: No such file or directory
/Users/allen/android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lstdc++
/Users/allen/android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lm
/Users/allen/android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lc
/Users/allen/android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldl
/Users/allen/android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: codec/common/src/WelsThreadPool.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
codec/encoder/core/src/au_set.o:au_set.cpp:function WelsEnc::WelsInitSps(WelsEnc::TagWelsSPS*, SSpatialLayerConfig*, WelsEnc::TagDLayerParam*, unsigned int, int, unsigned int, bool, bool, int, bool): error: undefined reference to 'memset'
codec/encoder/core/src/au_set.o:au_set.cpp:function WelsEnc::WelsInitSubsetSps(WelsEnc::TagSubsetSps*, SSpatialLayerConfig*, WelsEnc::TagDLayerParam*, unsigned int, int, unsigned int, bool, bool, int): error: undefined reference to 'memset'
.....

@GuangweiWang
Copy link
Collaborator

@Allen1207 could you please provide your local environment:

  1. commit of openh264
  2. MacOS version
  3. NDK version
  4. command line.

thanks.

@Allen1207
Copy link

@GuangweiWang ,

  1. 5c65ff3
  2. macOS Mojave 10.14.3
  3. NDK version r17c
  4. make OS=android NDKROOT=/Users/allen/android-ndk-r17c TARGET=android-28 ARCH=arm NDKLEVEL=28 clean
    make OS=android NDKROOT=/Users/allen/android-ndk-r17c TARGET=android-28 ARCH=arm NDKLEVEL=28

by the way, I changed some .mk files according to
http://www.phubber.com/2018/08/13/openh264-android-compile-ndkr17b/
to solve some errors of unable to find some .h files

@GuangweiWang
Copy link
Collaborator

@Allen1207
you'd better update your local code to latest commit. or at least after this commit "45d784dc7d92a29ef13f44e8157a2f9c443dab6e"( add clang support for arm/arm64/x86/x86_64 when NDK version is greater then 17)

@GuangweiWang
Copy link
Collaborator

@Allen1207
if you include that commit(45d784d). adding "NDK_TOOLCHAIN_VERSION=clang" to your command line will work when your NDK version is greater than 17.

@Allen1207
Copy link

hi @GuangweiWang ,

Yes, the commit (45d784d) can solve the "--sysroot " issue, but it still has the same problem as follows:

/Users/allen/android-ndk-r18b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_so.o: No such file or directory
/Users/allen/android-ndk-r18b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtend_so.o: No such file or directory
/Users/allen/android-ndk-r18b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lstdc++
/Users/allen/android-ndk-r18b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lm
/Users/allen/android-ndk-r18b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldl
/Users/allen/android-ndk-r18b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lc
/Users/allen/android-ndk-r18b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldl
/Users/allen/android-ndk-r18b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: codec/common/src/WelsThreadPool.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
codec/encoder/core/src/au_set.o:au_set.cpp:function WelsEnc::WelsInitSps(WelsEnc::TagWelsSPS*, SSpatialLayerConfig*, WelsEnc::TagDLayerParam*, unsigned int, int, unsigned int, bool, bool, int, bool): error: undefined reference to '__aeabi_memclr4'
codec/encoder/core/src/au_set.o:au_set.cpp:function WelsEnc::WelsInitSubsetSps(WelsEnc::TagSubsetSps*, SSpatialLayerConfig*, WelsEnc::TagDLayerParam*, unsigned int, int, unsigned int, bool, bool, int): error: undefined reference to '__aeabi_memclr4'
codec/encoder/core/src/encoder.o:encoder.cpp:function WelsEnc::WelsSetMemZero_c(void*, int): error: undefined reference to '__aeabi_memclr'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::SliceArgumentValidationFixedSliceMode(TagLogContext*, SSliceArgument*, RC_MODES, int, int): error: undefined reference to '__aeabi_memclr4'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::ParamValidation(TagLogContext*, WelsEnc::TagWelsSvcCodingParam*): error: undefined reference to 'log10'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::ParamValidation(TagLogContext*, WelsEnc::TagWelsSvcCodingParam*): error: undefined reference to 'floor'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::ParamValidationExt(TagLogContext*, WelsEnc::TagWelsSvcCodingParam*): error: undefined reference to '__aeabi_memclr4'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::AllocStrideTables(WelsEnc::TagWelsEncCtx**, int): error: undefined reference to '__aeabi_memclr8'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::AllocStrideTables(WelsEnc::TagWelsEncCtx**, int): error: undefined reference to '__aeabi_memcpy'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::AllocStrideTables(WelsEnc::TagWelsEncCtx**, int): error: undefined reference to '__aeabi_memclr'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::AllocStrideTables(WelsEnc::TagWelsEncCtx**, int): error: undefined reference to '__aeabi_memcpy'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::FreeMemorySvc(WelsEnc::TagWelsEncCtx**): error: undefined reference to 'free'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::WelsInitEncoderExt(WelsEnc::TagWelsEncCtx**, WelsEnc::TagWelsSvcCodingParam*, TagLogContext*, WelsEnc::TagExistingParasetList*): error: undefined reference to 'malloc'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::WelsInitEncoderExt(WelsEnc::TagWelsEncCtx**, WelsEnc::TagWelsSvcCodingParam*, TagLogContext*, WelsEnc::TagExistingParasetList*): error: undefined reference to 'operator new(unsigned int)'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::WelsInitEncoderExt(WelsEnc::TagWelsEncCtx**, WelsEnc::TagWelsSvcCodingParam*, TagLogContext*, WelsEnc::TagExistingParasetList*): error: undefined reference to '__aeabi_memcpy4'
codec/encoder/core/src/encoder_ext.o:encoder_ext.cpp:function WelsEnc::UpdateSlicepEncCtxWithPartition(WelsEnc::TagDqLayer*, int): error: undefined reference to '__aeabi_memclr'
...........

@sunjin1233
Copy link
Author

sunjin1233 commented Mar 9, 2019

@GuangweiWang Thank you. I have another error(The "android" command is deprecated) however openh264 have been built successfully. #2994

@GuangweiWang
Copy link
Collaborator

@sunjin1233
this error caused by using a higher SDK tool to build encoder & decoder demo program. The "android" tool does not support "update project" in the higher SDK version. Actually, the openh264 libraries have been built successfully. you can use the lower SDK version to build demo.

@GuangweiWang
Copy link
Collaborator

@Allen1207
It seems that you still use GCC to build. do this step:

  1. update your local openh264.
  2. make OS=android NDKROOT=/Users/allen/android-ndk-r17c TARGET=android-28 ARCH=arm NDKLEVEL=28 clean
  3. make OS=android NDKROOT=/Users/allen/android-ndk-r17c TARGET=android-28 ARCH=arm NDKLEVEL=28 NDK_TOOLCHAIN_VERSION=clang

Please let me know if you still have any issues.

@Allen1207
Copy link

@GuangweiWang ,
I deleted all the stuff and did it again, it finally succeeded!
I used the android ndk 1.7, sdk tools version < 25.2.3, and java version 1.8 .
Thank you for your help!

@martsa
Copy link

martsa commented Jul 29, 2020

@Allen1207
It seems that you still use GCC to build. do this step:

  1. update your local openh264.
  2. make OS=android NDKROOT=/Users/allen/android-ndk-r17c TARGET=android-28 ARCH=arm NDKLEVEL=28 clean
  3. make OS=android NDKROOT=/Users/allen/android-ndk-r17c TARGET=android-28 ARCH=arm NDKLEVEL=28 NDK_TOOLCHAIN_VERSION=clang

Please let me know if you still have any issues.

I am not able to build openh264 library for android .. please have a look at my issue ....#3318

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants