Complile error OpenH264 using Android NDK

拥有回忆 提交于 2019-12-12 02:05:58

问题


I am trying to compile the openh264 project for android but facing some trouble. I have setup the android_ndk-r10 properly and able to compile sample apps provided with the ndk.

Here's what i've done till now. Downloaded the zip of openh264 from here https://github.com/cisco/openh264. Navigated to the openh264-openh264v1.1\codec\build\android\dec\jni path using the cmd prompt and then fired the ndk-build command. It starts the build process but throws error while building libs for both encoder and decoder. Following is the error while building encoder lib....

[armeabi] Compile++ thumb: welsencdemo <= welsenc.cpp
[armeabi] Compile++ thumb: welsencdemo <= read_config.cpp
[armeabi] Compile++ thumb: welsencdemo <= myjni.cpp
[armeabi] Prebuilt       : libstlport_shared.so <= <NDK>/sources/cxx-stl/stlport
/libs/armeabi/thumb/
[armeabi] SharedLibrary  : libwelsencdemo.so
D:/Softwares/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windo
ws-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-android
eabi/bin/ld.exe: D:/Work/Android/OpenH264/openh264-openh264v1.1/codec/build/andr
oid/enc//obj/local/armeabi/objs/welsencdemo/__/__/__/__/console/enc/src/welsenc.
o: in function CreateSVCEncHandle(ISVCEncoder**):D:/Work/Android/OpenH264/openh2
64-openh264v1.1/codec/build/android/enc//jni/../../../../console/enc/src/welsenc
.cpp:931: error: undefined reference to 'WelsCreateSVCEncoder'
D:/Softwares/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windo
ws-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-android
eabi/bin/ld.exe: D:/Work/Android/OpenH264/openh264-openh264v1.1/codec/build/andr
oid/enc//obj/local/armeabi/objs/welsencdemo/__/__/__/__/console/enc/src/welsenc.
o: in function DestroySVCEncHandle(ISVCEncoder*):D:/Work/Android/OpenH264/openh2
64-openh264v1.1/codec/build/android/enc//jni/../../../../console/enc/src/welsenc
.cpp:937: error: undefined reference to 'WelsDestroySVCEncoder'
collect2: ld returned 1 exit status
make.exe: *** [D:/Work/Android/OpenH264/openh264-openh264v1.1/codec/build/androi
d/enc//obj/local/armeabi/libwelsencdemo.so] Error 1

Similarly while building the decoder lib facing an error as below....

[armeabi] Compile++ thumb: welsdecdemo <= h264dec.cpp
[armeabi] Compile++ thumb: welsdecdemo <= read_config.cpp
[armeabi] Compile++ thumb: welsdecdemo <= d3d9_utils.cpp
[armeabi] Compile++ thumb: welsdecdemo <= myjni.cpp
[armeabi] Prebuilt       : libstlport_shared.so <= <NDK>/sources/cxx-stl/stlport
/libs/armeabi/thumb/
[armeabi] SharedLibrary  : libwelsdecdemo.so
D:/Softwares/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windo
ws-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-android
eabi/bin/ld.exe: D:/Work/Android/OpenH264/openh264-openh264v1.1/codec/build/andr
oid/dec//obj/local/armeabi/objs/welsdecdemo/__/__/__/__/console/dec/src/h264dec.
o: in function DecMain(int, char**):D:/Work/Android/OpenH264/openh264-openh264v1
.1/codec/build/android/dec//jni/../../../../console/dec/src/h264dec.cpp:417: err
or: undefined reference to 'WelsCreateDecoder'
D:/Softwares/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/windo
ws-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-android
eabi/bin/ld.exe: D:/Work/Android/OpenH264/openh264-openh264v1.1/codec/build/andr
oid/dec//obj/local/armeabi/objs/welsdecdemo/__/__/__/__/console/dec/src/h264dec.
o: in function DecMain(int, char**):D:/Work/Android/OpenH264/openh264-openh264v1
.1/codec/build/android/dec//jni/../../../../console/dec/src/h264dec.cpp:447: err
or: undefined reference to 'WelsDestroyDecoder'
collect2: ld returned 1 exit status
make.exe: *** [D:/Work/Android/OpenH264/openh264-openh264v1.1/codec/build/androi
d/dec//obj/local/armeabi/libwelsdecdemo.so] Error 1

Before trying to build I did not make any changes to the openh264 code that I downloaded. Its a linking error, I tried to fix by making changes to the welsdecdemo.mk file that refers to the .h and .cpp files that are available in the code, but still getting the same error. As am a java developer and new with NDK and cpp am facing a tough time. Request your help, with some useful pointers in the right direction.


回答1:


Please see README.md in OpenH264 for instructions on how to build it for android.

The android project that you've found in codec\build\android\dec only builds a test example of a decoder - it doesn't build the codec itself. The main makefile in the root of the project (which README.md describes how to use) will both build the codec itself and the test examples.




回答2:


Thanks to mstorsjo I could successfully compile the openh264 libs and also run the android decoder/encoder sample app. The decoding/encoding works great.

The steps to compile the OpenH264 project(using windows) for Android are as mentioned by mstorsjo :-

You need 1) MSYS 2) android-ndk 3) OpenH264 project

Then from within MSYS, do "make OS=android NDKROOT=/unix/path/to/ndk TARGET=9 libopenh264.so". Now you can build the sample projects in codec/build/android just as you tried to do before.

Once the OpenH264 project is built then follow the steps I mentioned in my original question to build the sample android apps for decoder/encoder.



来源:https://stackoverflow.com/questions/25243003/complile-error-openh264-using-android-ndk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!