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

building ffmpeg for android on Mac fails for LAME, SPEEX and OPENCORE_AMR #133

Closed
kristofgiber opened this issue Jan 1, 2016 · 16 comments
Closed

Comments

@kristofgiber
Copy link

I know about the similar issue #45 by IFDeveloper but that's been marked solved while none of the suggested solutions seem to work for me.
I run:

sudo ANDROID_NDK=/Users/user/Android/android-ndk-r10e/ bash cppbuild.sh -platform android-arm install

It goes through opencv with success but fails during ffmpeg with the following error:

configure: error: in `/Users/user/Code/git/javacpp-presets/ffmpeg/cppbuild/android-arm/lame-3.99.5':
configure: error: C preprocessor "/lib/cpp" fails sanity check

Even if I remove LAME from the cppbuild.sh it gives the same error for SPEEX and OPENCORE_AMR. If I get rid of all 3, it finishes ffmpeg build but I need them later in the build process.

@saudet
Copy link
Member

saudet commented Jan 3, 2016

Should be fixed in this commit: 85dcf0b

Thanks for reporting!

@kristofgiber
Copy link
Author

Thank you Samuel, I've tried with your commits and it does make some progress but eventually it still fails to build with the above command when it gets to LAME in ffmpeg. The error is different though:

libtool: link: /Users/user/Android/android-ndk-r10e//toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc -Wall -pipe --sysroot=/Users/user/Android/android-ndk-r10e//platforms/android-14/arch-arm/ -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -fno-common -nostdlib -Wl,--fix-cortex-a8 -o lame lame_main.o main.o brhist.o console.o get_audio.o lametime.o parse.o timestatus.o  ../libmp3lame/.libs/libmp3lame.a -lgcc -ldl -lz -lm -lc
/Users/user/Android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: ../libmp3lame/.libs/libmp3lame.a: no archive symbol table (run ranlib)
lame_main.o:lame_main.c:function init_files: error: undefined reference to 'lame_get_decode_only'
lame_main.o:lame_main.c:function printInputFormat: error: undefined reference to 'lame_get_version'
lame_main.o:lame_main.c:function printInputFormat: error: undefined reference to 'lame_get_out_samplerate'
lame_main.o:lame_main.c:function lame_decoder: error: undefined reference to 'lame_get_num_channels'
lame_main.o:lame_main.c:function lame_decoder: error: undefined reference to 'lame_get_in_samplerate'
...
... (many more like that)
...
timestatus.o:timestatus.c:function encoder_progress_begin: error: undefined reference to 'lame_print_internals'
timestatus.o:timestatus.c:function encoder_progress: error: undefined reference to 'lame_get_frameNum'
collect2: error: ld returned 1 exit status
make[2]: *** [lame] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

@saudet
Copy link
Member

saudet commented Jan 11, 2016

Looks like we'll need to redirect ar and ranlib as well. I've updated that in this commit: 8cf3365

@kristofgiber
Copy link
Author

Okay thank you for the great fix, it's finished ffmpeg successfully, but it still can't finish the entire build. There's an fftw error this time. Should I open a new issue with this? In any case, here's the error log:

checking command to parse nm output from /Users/user/Android/android-ndk-r10e//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-gcc -std=gnu99 object... failed
checking for sysroot... /Users/user/Android/android-ndk-r10e//platforms/android-14/arch-x86/
checking for i686-linux-android-mt... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... /lib/cpp
configure: error: in `/Users/user/Code/git/javacpp-presets/fftw/cppbuild/android-x86/fftw-3.3.4':
configure: error: C preprocessor "/lib/cpp" fails sanity check

saudet added a commit that referenced this issue Jan 16, 2016
@saudet
Copy link
Member

saudet commented Jan 16, 2016

Yes, there were a few issues left with that on Mac OS X. I think I've managed to fix everything, so check out the latest commit! Thanks for testing :)

@kristofgiber
Copy link
Author

Awesome, thanks to the last commit it's done with fftw now and progressed even farther in the build, it's not finished yet though. Fails with leptonica:

libtool: compile:  /Users/user/Android/android-ndk-r10e//toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++ -DHAVE_CONFIG_H -I. --sysroot=/Users/user/Android/android-ndk-r10e//platforms/android-14/arch-arm/ -DANDROID --sysroot=/Users/user/Android/android-ndk-r10e//platforms/android-14/arch-arm/ -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -MT tif_stream.lo -MD -MP -MF .deps/tif_stream.Tpo -c tif_stream.cxx  -fPIC -DPIC -o tif_stream.o
tif_stream.cxx:31:20: fatal error: iostream: No such file or directory
 #include <iostream>
                    ^
compilation terminated.
make[2]: *** [tif_stream.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f .deps/tif_unix.Tpo .deps/tif_unix.Plo
mv -f .deps/tif_zip.Tpo .deps/tif_zip.Plo
libtool: warning: library '/Users/user/Code/git/javacpp-presets/leptonica/cppbuild/android-arm/lib//libjpeg.la' was moved.
libtool: warning: library '/Users/user/Code/git/javacpp-presets/leptonica/cppbuild/android-arm/lib//libjpeg.la' was moved.
libtool: link: /Users/user/Android/android-ndk-r10e//toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc -DS_IREAD=S_IRUSR -DS_IWRITE=S_IWUSR -D__native_client__ -pthread -I/Users/user/Code/git/javacpp-presets/leptonica/cppbuild/android-arm/include/ -I/Users/user/Android/android-ndk-r10e//sources/android/cpufeatures/ --sysroot=/Users/user/Android/android-ndk-r10e//platforms/android-14/arch-arm/ -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 --sysroot=/Users/user/Android/android-ndk-r10e//platforms/android-14/arch-arm/ -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wall -W -nostdlib -Wl,--fix-cortex-a8 -o mkg3states mkg3states.o  -L/Users/user/Code/git/javacpp-presets/leptonica/cppbuild/android-arm/lib/ ../port/.libs/libport.a /Users/user/Code/git/javacpp-presets/leptonica/cppbuild/android-arm/lib//libjpeg.a -lgcc -ldl -lz -lm -lc -pthread
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

@saudet
Copy link
Member

saudet commented Jan 16, 2016

Right, we need to make sure the CXX, CPPFLAGS, CFLAGS, and CXXFLAGS environment variables are all empty, or that can happen for some reason. Fixed in the latest commit.

@kristofgiber
Copy link
Author

Great, it goes without error till almost the last module, it fails at tesseract:

Installing "caffe"
~/Code/git/javacpp-presets/caffe/cppbuild ~/Code/git/javacpp-presets
Error: Platform "android-arm" is not supported
~/Code/git/javacpp-presets
Installing "cuda"
~/Code/git/javacpp-presets/cuda/cppbuild ~/Code/git/javacpp-presets
Error: Platform "android-arm" is not supported
~/Code/git/javacpp-presets
Installing "tensorflow"
~/Code/git/javacpp-presets/tensorflow/cppbuild ~/Code/git/javacpp-presets
Error: Platform "android-arm" is not supported
~/Code/git/javacpp-presets

@saudet
Copy link
Member

saudet commented Jan 17, 2016

What is the error you get for tesseract?

@kristofgiber
Copy link
Author

Apologies, I meant to write fails *AFTER tesseract. For the last 3 modules, caffe, cuda and tensorflow, shows error 'android-arm is not supported'. Is this a build error or just a compatibility issue with armeabi? Anything we should/can do about this or should I just remove those modules for armeabi platform?

@saudet
Copy link
Member

saudet commented Jan 17, 2016

@kristofgiber It just means that builds are not available. If you would like to contribute builds for those platforms, it would be most welcome!

@kristofgiber
Copy link
Author

Okay but I'm still not at that stage apparently: even though my cppbuild.sh build finished correctly (except for the modules unavailable for android), when I run maven command

mvn clean install -Pandroid-arm -Dplatform.root=/Users/user/Android/android-ndk-r10e/

it fails with opencv with this error:

[INFO] JavaCPP Presets for OpenCV ......................... FAILURE [01:42 min]
[INFO] BUILD FAILURE
[ERROR] Failed to execute goal org.bytedeco:javacpp:1.2-SNAPSHOT:build (process-classes) on project opencv: Failed to execute JavaCPP Builder: Cannot run program "toolchains/arm-linux-androideabi-4.9/prebuilt/macosx-x86_64/bin/arm-linux-androideabi-g++": error=2, No such file or directory -> [Help 1]

@saudet
Copy link
Member

saudet commented Jan 17, 2016

@kristofgiber Check the comments inside the pom.xml file...

@kristofgiber
Copy link
Author

Awesome, followed the comment instructions and it's completed everything. Thanks for all the help Samuel!

As a short summary for anyone else trying to set up javacpp for android platform from complete scratch on Mac:

  1. SOFTWARE INSTALLATIONS:

Install latest android NDK and Xcode
Install whatever else of these you need (sorry if some of these aren't necessary for android, just grabbing from my old notes):
brew install git bash
brew install llvm --with-clang --with-asan --HEAD
brew install caskroom/cask/brew-cask
brew cask install cuda java
brew install cmake libusb maven nasm yasm xz bazel ant

  1. BUILD FOR ANDROID PLATFORM:

git clone https://github.com/bytedeco/javacpp.git
git clone https://github.com/bytedeco/javacpp-presets.git

cd javacpp

mvn install

cd ../javacpp-presets

ANDROID_NDK=path_to_android_ndk/ bash cppbuild.sh -platform android-arm install

mvn clean install -Dplatform=android-arm -Dplatform.root=path_to_android_ndk/ -Dplatform.compiler=path_to_arm-linux-androideabi-g++/arm-linux-androideabi-g++

Repeat last 2 commands for platform android-x86 as well.

The jar files will be generated in the target folder of each module.

@saudet
Copy link
Member

saudet commented Feb 7, 2016

@kristofgiber I've updated the wiki pages to update and clarify a few things, based on your comments. Let me know if you see anything else we could improve! Thanks

@saudet
Copy link
Member

saudet commented May 19, 2016

Should all be fixed in version 1.2. Let me know if you still have issues with that. Thanks!

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

No branches or pull requests

2 participants