Building .so file for OpenH264 android - android

I am trying to build .so file for different cpu architecture in OpenH264.
README.md of OpenH264 suggest
add "ARCH=mips" or "ARCH=x86". To build for the older armeabi ABI (which has
armv5te as baseline), add "APP_ABI=armeabi" (ARCH=arm is implicit).
So I fired following command
For x86
make os=android NDKROOT=/home/neosoft/android-ndk-r10d/ ARCH=x86 TARGET=android-12
I get something like
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [libopenh264.so] Error 1
and when I try to build it with armeabi
make os=android NDKROOT=/home/neosoft/android-ndk-r10d/ ARCH=armeabi TARGET=android-12
I get
cc -O3 -DHAVE_NEON -Wall -fno-strict-aliasing -fPIC -DLINUX -MMD -MP -Icodec/common/arm/ -march=armv7-a -mfpu=neon -Icodec/api/svc -Icodec/common/inc -c -o codec/common/arm/copy_mb_neon.o codec/common/arm/copy_mb_neon.S
cc: error: unrecognized command line option ‘-mfpu=neon’
make: *** [codec/common/arm/copy_mb_neon.o] Error 1
can somebody point me how to compile this lib for different cpu architecture.

For linux :
a. First run this command
export PATH=ANDROID_SDK_PATH/tools:$PATH
b. Now run this for x86 ARCH.
make install os=android NDKROOT=/home/neosoft/android-ndk-r10d TARGET=android-14 ARCH=x86
For other Arch just run this by replacing ARCH type
make os=android NDKROOT=/home/neosoft/android-ndk-r10d TARGET=android-14 ARCH=armeabi
For Windows : a. Install MinGW( https://www.youtube.com/watch?v=DHekr3EtDOA). b. Install MYSY in MinGW/bin folder.
c. Install nasm in MinGW/bin/1.0/bin folder.
d. Go to MinGW\bin\1.0\ location and run msys.bat.
e. Run below command by replacing ARCH type.
make install os=android NDKROOT=/home/neosoft/android-ndk-r10d TARGET=android-14 ARCH=x86

Related

After NDK22 upgrade the build fails with "cannot open crtbegin_so.o / crtend_so.o" error

My app is using Android SDK and NDK. Until recently I was using SDK27 and NDK17c and all was working just fine. Then I decided to update my app and switched to SDK29 and NDK22 and the hell broke loose.
After taking into account the NDK directory structure changes and getting rid of all the remnants of GCC I was able to compile my .so library but during the build, there is this error:
19:38:58 **** Incremental Build of configuration android_ndk22_android-29-arm64-v8a for project MyProjectJNI ****
make all
Building target: ../../../../../../bin/android_ndk22_android-29-arm64-v8a/libMyProjectJNI.so
Invoking: LLVM Clang C++ linker
clang++ -v -L"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\bin" -L"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29" -L"../../../../../../bin/android_ndk22_android-29-arm64-v8a/" -L"D:\Projects\Libs\boost_1_67_0/android_ndk22_android-29-arm64-v8a/lib/" -L"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/sources/cxx-stl/llvm-libc++/libs/arm64-v8a" -L"D:\Projects\Libs\boost_1_67_0/lib/" -L"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x" --sysroot="C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot/" -target aarch64-linux-android29 -shared -std=c++11 -O1 --no-undefined -Wl,-verbose -o "../../../../../../bin/android_ndk22_android-29-arm64-v8a/libMyProjectJNI.so" ./BaseJNI.bc ./CalibrationJNI.bc ./UtilsJNI.bc ./dllmain.bc -lMyOtherLib -lboost_system -lboost_filesystem -lboost_thread -lboost_atomic -lboost_chrono -ljnigraphics -llog
clang version 3.7.0 (tags/RELEASE_370/final)
Target: aarch64--linux-android
Thread model: posix
"C:\\Program Files\\LLVM\\bin\\clang++.exe" -cc1 -triple aarch64--linux-android29 -emit-obj -disable-free -main-file-name BaseJNI.bc -mrelocation-model pic -pic-level 1 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -target-feature +neon -target-abi aapcs -backend-option -aarch64-fix-cortex-a53-835769=1 -v -dwarf-column-info -resource-dir "C:\\Program Files\\LLVM\\bin\\..\\lib\\clang\\3.7.0" -O1 -std=c++11 -fdebug-compilation-dir "D:\\Projects\\Development\\trunk\\Host\\dev\\src\\MyProjectJNI\\android_ndk22_android-29-arm64-v8a" -ferror-limit 19 -fmessage-length 0 -mstackrealign -fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -o "C:\\Users\\UserPro\\AppData\\Local\\Temp\\BaseJNI-9a764d.o" -x ir ./BaseJNI.bc
clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target x86_64-w64-windows-gnu
"C:\\Program Files\\LLVM\\bin\\clang++.exe" -cc1 -triple aarch64--linux-android29 -emit-obj -disable-free -main-file-name CalibrationJNI.bc -mrelocation-model pic -pic-level 1 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -target-feature +neon -target-abi aapcs -backend-option -aarch64-fix-cortex-a53-835769=1 -v -dwarf-column-info -resource-dir "C:\\Program Files\\LLVM\\bin\\..\\lib\\clang\\3.7.0" -O1 -std=c++11 -fdebug-compilation-dir "D:\\Projects\\Development\\trunk\\Host\\dev\\src\\MyProjectJNI\\android_ndk22_android-29-arm64-v8a" -ferror-limit 19 -fmessage-length 0 -mstackrealign -fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -o "C:\\Users\\UserPro\\AppData\\Local\\Temp\\CalibrationJNI-cc675c.o" -x ir ./CalibrationDataJNI.bc
clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target x86_64-w64-windows-gnu
"C:\\Program Files\\LLVM\\bin\\clang++.exe" -cc1 -triple aarch64--linux-android29 -emit-obj -disable-free -main-file-name UtilsJNI.bc -mrelocation-model pic -pic-level 1 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -target-feature +neon -target-abi aapcs -backend-option -aarch64-fix-cortex-a53-835769=1 -v -dwarf-column-info -resource-dir "C:\\Program Files\\LLVM\\bin\\..\\lib\\clang\\3.7.0" -O1 -std=c++11 -fdebug-compilation-dir "D:\\Projects\\Development\\trunk\\Host\\dev\\src\\MyProjectJNI\\android_ndk22_android-29-arm64-v8a" -ferror-limit 19 -fmessage-length 0 -mstackrealign -fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -o "C:\\Users\\UserPro\\AppData\\Local\\Temp\\UtilsJNI-6102ad.o" -x ir ./CalibrationJNI
clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target x86_64-w64-windows-gnu
"C:\\Users\\UserPro\\AppData\\Local\\Android\\sdk\\ndk\\22.1.7171670\\toolchains\\llvm\\prebuilt\\windows-x86_64\\aarch64-linux-android\\bin\\ld.exe" "--sysroot=C:\\Users\\UserPro\\AppData\\Local\\Android\\sdk\\ndk\\22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot/" --eh-frame-hdr -m aarch64linux -shared -o ../../../../../../bin/android_ndk22_android-29-arm64-v8a/libMyProjectJNI.so crtbegin_so.o "-LC:\\Users\\UserPro\\AppData\\Local\\Android\\sdk\\ndk\\22.1.7171670\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin" "-LC:\\Users\\UserPro\\AppData\\Local\\Android\\sdk\\ndk\\22.1.7171670\\toolchains\\llvm\\prebuilt\\windows-x86_64\\sysroot\\usr\\lib\\aarch64-linux-android\\29" -L../../../../../../bin/android_ndk22_android-29-arm64-v8a/ "-LD:\\Projects\\Libs\\boost_1_67_0/android_ndk22_android-29-arm64-v8a/lib/" "-LC:\\Users\\UserPro\\AppData\\Local\\Android\\sdk\\ndk\\22.1.7171670/sources/cxx-stl/llvm-libc++/libs/arm64-v8a" "-LD:\\Projects\\Libs\\boost_1_67_0/lib/" "-LC:\\Users\\UserPro\\AppData\\Local\\Android\\sdk\\ndk\\22.1.7171670/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x" "-LC:\\Users\\UserPro\\AppData\\Local\\Android\\sdk\\ndk\\22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot//usr/lib" --no-undefined -verbose "C:\\Users\\UserPro\\AppData\\Local\\Temp\\BaseFrameJNI-9a764d.o" "C:\\Users\\UserPro\\AppData\\Local\\Temp\\CalibrationJNI-cc675c.o" "C:\\Users\\UserPro\\AppData\\Local\\Temp\\UtilsJNI-09f434.o" "C:\\Users\\UserPro\\AppData\\Local\\Temp\\dllmain-63e5e7.o" -lMyOtherLib -lboost_system -lboost_filesystem -lboost_thread -lboost_atomic -lboost_chrono -ljnigraphics -llog -lstdc++ -lm -lgcc -ldl -lc -lgcc -ldl crtend_so.o
ld: crtbegin_so.o
ld: error: cannot open crtbegin_so.o: No such file or directory
ld: C:\Users\UserPro\AppData\Local\Temp\BaseJNI-9a764d.o
ld: C:\Users\UserPro\AppData\Local\Temp\CalibrationJNI-cc675c.o
ld: C:\Users\UserPro\AppData\Local\Temp\UtilsJNI-09f434.o
ld: C:\Users\UserPro\AppData\Local\Temp\dllmain-63e5e7.o
ld: ../../../../../../bin/android_ndk22_android-29-arm64-v8a/liblMyOtherLib.so
ld: D:\Projects\Libs\boost_1_67_0/android_ndk22_android-29-arm64-v8a/lib/libboost_system.a
ld: D:\Projects\Libs\boost_1_67_0/android_ndk22_android-29-arm64-v8a/lib/libboost_filesystem.a
ld: D:\Projects\Libs\boost_1_67_0/android_ndk22_android-29-arm64-v8a/lib/libboost_thread.a
ld: D:\Projects\Libs\boost_1_67_0/android_ndk22_android-29-arm64-v8a/lib/libboost_atomic.a
ld: D:\Projects\Libs\boost_1_67_0/android_ndk22_android-29-arm64-v8a/lib/libboost_chrono.a
ld: C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29\libjnigraphics.so
ld: C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29\liblog.so
ld: C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29\libstdc++.so
ld: C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29\libm.so
ld: C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x\libgcc.a
ld: C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29\libdl.so
ld: C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29\libc.so
ld: C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x\libgcc.a
ld: C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29\libdl.so
ld: crtend_so.o
ld: error: cannot open crtend_so.o: No such file or directory
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [makefile:53: ../../../../../../bin/android_ndk22_android-29-arm64-v8a/libMyProjectJNI.so] Error 1
The files that the linker cannot find, crtbegin_so.o and crtend_so.o, are definitely here:
C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29\
I know that the major change between ndk17 and ndk22 is that
"Clang, binutils, the sysroot, and other toolchain pieces are now all
installed to $NDK/toolchains/llvm/prebuilt/ and Clang will
automatically find them. "
It looks to me like the linker was able to automatically find .so libraries but cannot find .o objects and is ignoring all paths I supply. Has anybody else encountered this problem? Any suggestions on how to solve it?
UPDATE: I respectfully disagree with the editing of the question. The switching from ndk17 to ndk22 includes switching from GCC to LLVM and probably the problem lies somewhere there.
UPDATE2
My clang++ command-line options for compiler:
-DNDEBUG
-I"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/sources/cxx-stl/llvm-libc++/include"
-I"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/sysroot/usr/include/aarch64-linux-android"
-I"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/sources/android/cpufeatures"
-I"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/sysroot/usr/include"
-I"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include"
-I"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/x86_64-linux-android"
-I"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/aarch64-linux-android/29"
-I"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22\AppData\Local\Android\sdk\ndk\22.1.7171670/sysroot/usr/include/arm-linux-androideabi"
-I../../../include -I../../CommonUtilities
-I"$(BOOST_PATH)" -I../../../../../../Common/include -O2 -emit-llvm -g -Wall -c -fmessage-length=0 -target aarch64-linux-android -std=c++0x
and for linker:
-v
-L"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\bin"
-L"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\29"
-L"../../../../../../bin/android_ndk23_android-29-arm64-v8a/"
-L"D:\Projects\Libs\boost_1_67_0/android_ndk23_android-29-arm64-v8a/lib/"
-L"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/sources/cxx-stl/llvm-libc++/libs/arm64-v8a"
-L"D:\Projects\Libs\boost_1_67_0/lib/"
-L"C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x"
--sysroot="C:\Users\UserPro\AppData\Local\Android\sdk\ndk\22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot/"
-target aarch64-linux-android -shared -std=c++11 -O1 --no-undefined -Wl,-verbose
I ended up using -nostartfiles option. Worked for me

How to build boost for android as shared library with c++11 support

I am trying to build boost_1.60.0 (as shared library) for android with c++11 support. I am using the latest ndk (currently android-ndk-r10e). The build host is Windows-10.
This is for a non-opensource project. So as far as I understand I cannot use gnustl_shared, and I need to use c++_shared as the android c++ runtime.
my project-config.jam looks like this:
androidNDKRoot = c:/android-ndk-r10e ;
using gcc : android :
$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ :
<root>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/
<compileflags>-MMD
<compileflags>-MP
<compileflags>-MF
<compileflags>-fpic
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector
<compileflags>-no-canonical-prefixes
<compileflags>-march=armv5te
<compileflags>-mtune=xscale
<compileflags>-msoft-float
<compileflags>-fno-rtti
<compileflags>-mthumb
<compileflags>-Os
<compileflags>-g
<compileflags>-DNDEBUG
<compileflags>-fomit-frame-pointer
<compileflags>-fno-strict-aliasing
<compileflags>-finline-limit=64
<compileflags>-IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/libcxx/include
<compileflags>-IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../llvm-libc++abi/libcxxabi/include
<compileflags>-IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../../android/support/include
<compileflags>-IC:/android-ndk-r10e/platforms/android-9/arch-arm/usr/include
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-DUNIX
<compileflags>-DANDROID
<compileflags>-Wl,--no-undefined
<cxxflags>-fexceptions
<linkflags>-lc++_shared
<archiver>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ar
<ranlib>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ranlib
;
the build command is:
b2 --toolset=gcc-android cxxflags="-std=c++11 " --prefix=..\boost_android_arm --builddir=./boost_android_arm/builddir target-os=linux --with-filesystem define=BOOST_FILESYSTEM_VERSION=3 link=shared runtime-link=shared threading=multi
In order to determine the parameters in the project-config.jam I've build a sample shared library using the ndk-build, get its debug messages, and extracted the compile and link commands it uses.
compile:
C:\android-ndk-r10e\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-g++.exe,C:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs/someLib/./Unity1.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Ijni/../../library/../../../../ -Ijni/../../library/../../../../src/ -IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/libcxx/include -IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../llvm-libc++abi/libcxxabi/include -IC:/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../../android/support/include -Ijni/../../library -DANDROID -DHAVE_CONFIG_H -DSESTEK_ANDROID_XERCES_HACK -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -fno-strict-aliasing -frtti -fexceptions -DUNIX -DANDROID -IC:/android-ndk-r10e/platforms/android-9/arch-arm/usr/include -c jni/../../library/./Unity1.cpp -o ./obj/local/armeabi/objs/someLib/./Unity1.o,...)
link:
C:\android-ndk-r10e\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-g++.exe,C:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -Wl,-soname,libsomeLib.so -shared --sysroot=C:/android-ndk-r10e/platforms/android-9/arch-arm ./obj/local/armeabi/objs/someLib/./Unity1.o -lgcc ./obj/local/armeabi/libc++_shared.so -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -mthumb -lc -lm -o ./obj/local/armeabi/libsomeLib.so,...)
For brevity I've only build filesystem for this trial but in the end I plan to build at least thread, filesystem, date_time, asio and log libraries.
Finally the error I get is as follows.
...patience...
...found 660 targets...
...updating 13 targets...
gcc.compile.c++ bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o
gcc.link.dll bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\libboost_system-gcc-mt-1_60.so.1.60.0
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot open crtbegin_so.o: No such file or directory
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lrt
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot open crtend_so.o: No such file or directory
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lc++_shared
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lstdc++
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lm
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lc
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -ldl
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lc
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
./boost/system/detail/error_code.ipp:458: error: undefined reference to '__dso_handle'
./boost/system/detail/error_code.ipp:464: error: undefined reference to '__dso_handle'
./boost/system/detail/error_code.ipp:158: error: undefined reference to '__dso_handle'
collect2.exe: error: ld returned 1 exit status
"c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++" -o "bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\libboost_system-gcc-mt-1_60.so.1.60.0" -shared -Wl,--start-group "bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\error_code.o" -Wl,-Bstatic -Wl,-Bdynamic -lrt -Wl,--end-group -lc++_shared -pthread
...failed gcc.link.dll bin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi\libboost_system-gcc-mt-1_60.so.1.60.0...
...skipped <pstage\lib>libboost_system-gcc-mt-1_60.so.1.60.0 for lack of <pbin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi>libboost_system-gcc-mt-1_60.so.1.60.0...
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\codecvt_error_category.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\operations.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\path.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\path_traits.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\portability.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\unique_path.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\utf8_codecvt_facet.o
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi\windows_file_codecvt.o
...skipped <pbin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi>libboost_filesystem-gcc-mt-1_60.so.1.60.0 for lack of <pbin.v2\libs\system\build\gcc-android\release\target-os-linux\threading-multi>libboost_system-gcc-mt-1_60.so.1.60.0...
...skipped <pstage\lib>libboost_filesystem-gcc-mt-1_60.so.1.60.0 for lack of <pbin.v2\libs\filesystem\build\gcc-android\release\target-os-linux\threading-multi>libboost_filesystem-gcc-mt-1_60.so.1.60.0...
...failed updating 1 target...
...skipped 3 targets...
...updated 9 targets...
The error tells that it needs the directory to find the necessary libraries, but the problem is that under android ndk there are several files with names rt and crtbegin_so.o and such. I guess I need to make the compiler determine the correct directory itself.
With all being said what I need actually is to build boost shared libraries for android with c++11 support. So I may accept your help either by pointing me in the right direction using the above build parameters or providing me a working sample so I can work out the details myself.
Oh also one more thing: if I use link=static instead of link=shared in the build command the build succeeds. But I have not tried the produced static libraries.
Building Boost on Linux using the NDK
I know you're asking about Windows, but I wanted to do this on macOS and it failed with nearly the exact error. I finally broke down and did it on my linode server it worked without a problem. This says to me that they aren't really doing a good job of testing other platforms. Compiling static only on macOS works as you also discovered on Windows.
Point of reference
NDK R13
Boost 1.62.0
Tested with clang++; g++ also works
If you're wondering why I'm using clang, the Release Notes have the following message:
GCC is no longer supported. It will not be removed from the NDK just
yet, but is no longer receiving backports. It cannot be removed until
after libc++ has become stable enough to be the default, as some parts
of gnustl are still incompatible with Clang. It will likely be removed
after that point.
user-config.jam
I placed this file in my home directory. Yuck.
androidNDKRoot = /path/to/ndk-R13-standalone ;
using clang : android
:
$(androidNDKRoot)/bin/arm-linux-androideabi-clang++
:
;
Modifying libtool.m4 in boost to avoid versioning of the libraries
libtool.m4 under tools/build/src/engine/boehm_gc/libtool.m4 in the boost source has no reference to android and you'll need to change version_type=linux in the section linux*) to version_type=none. This will cause symbolic links to appear without the version number appended to the end linked to the versioned shared libraries in the output.
Building
Target OS MUST be android to avoid the -lrt flag being passed which will cause shared linking to fail.
./b2 \
-d+2 \
-j 4 \
--reconfigure \
target-os=android \
toolset=clang-android \
include=${ANDROID_NDK_STANDALONE}/include/c++/4.9.x \
link=static,shared \
variant=debug,release \
threading=multi \
--layout=versioned \
--prefix=${BOOST_INSTALL_DIR} \
install
A relevant information is here (Boost for Android), where they have been able to successfully build the shared libraries, but it seems that the resulting files have a version suffix which android can't handle. Also one can't just rename the binary because the file name is hardcoded in it. One way out, as per the last post, is to set the variable version_type to none (version_type=none) in the linux section of file. In your case, the build setup could be a little different, but it may be worthwhile to take a look at the changes they made at that discussion.
user-config.jam
If you want to find boost from cmake(find_package) you must use the version of compiler, and not android like the top answer, in your user-config.jam like below according to boost doc.
androidNDKRoot = /path/to/ndk-R13-standalone ;
using clang : 8.0.1
:
$(androidNDKRoot)/bin/arm-linux-androideabi-clang++
:
;
My answer for me in future. How to build latest Boost(1.79.0) with latest NDK(24.0) on Windows PC for Android.
Go to your downloaded boost_1_79_0 unpacked directory and build b2 tool:
.\bootstrap.bat
Check b2 tools is ready:
b2 --version
B2 4.8-git <-- possible output
create file user-config.jam in %HOME% directory with content like that(example):
using clang : arm64 : c\:/Users/l_chayka/Downloads/android-ndk-r24/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android21-clang++.cmd : <cxxflags>-std=c++20 ;
using clang : arm : c\:/Users/l_chayka/Downloads/android-ndk-r24/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi21-clang++.cmd : <cxxflags>-std=c++20 ;
using clang : x86 : c\:/Users/l_chayka/Downloads/android-ndk-r24/toolchains/llvm/prebuilt/windows-x86_64/bin/i686-linux-android21-clang++.cmd : <cxxflags>-std=c++20 ;
using clang : x86_64 : c\:/Users/l_chayka/Downloads/android-ndk-r24/toolchains/llvm/prebuilt/windows-x86_64/bin/x86_64-linux-android21-clang++.cmd : <cxxflags>-std=c++20 ;
Go to boost root and try to build for every Android architecture (arm, arm64, x86, x86_64) example:
c:\Users\l_chayka\Downloads\boost_1_79_0>b2.exe toolset=clang-x86_64 target-os=android link=static variant=debug threading=multi --layout=versioned --prefix=c:/boost-x64_86/ install
c:\Users\l_chayka\Downloads\boost_1_79_0>b2.exe toolset=clang-x86 target-os=android link=static variant=debug threading=multi --layout=versioned --prefix=c:/boost-x86/ install
c:\Users\l_chayka\Downloads\boost_1_79_0>b2.exe toolset=clang-arm target-os=android link=static variant=debug threading=multi --layout=versioned --prefix=c:/boost-arm/ install
c:\Users\l_chayka\Downloads\boost_1_79_0>b2.exe toolset=clang-arm64 target-os=android link=static variant=debug threading=multi --layout=versioned --prefix=c:/boost-arm64/ install
Now check you instalation prefix path.

cross compile c program for android

I have a c program that uses -lpcap, -lm, and -lpthread. I see the libraries in /usr/arm-linuxgnueabi/lib/. However, if I compile using the command
arm-linux-gnueabi-gcc -static *.c -L/usr/arm-linux-gnueabi/lib/ -lpcap -lm -lpthread -o dumps/forandroid
It gives the following error:
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find crt1.o: No such file or directory<br>
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find crti.o: No such file or directory<br>
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find -lpcap<br>
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find -lm<br>
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find -lpthread
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find -lc<br>
collect2: error: ld returned 1 exit status
How can I give the library path properly? I am trying to compile the program for android emulator running android 5.1. I am using mint 17.2 64 bit amd machine.
I solved the problem using ndk toolchain. I compiled libpcap for arm-linux and used the library. The following command does the job:
arm-linux-androideabi-gcc --sysroot=/home/shahrear/Android/ndk/platforms/android-21/arch-arm -fpie -fpic -I./pcap -I. *.c -L./lib -pie -lm -lpcap -o dumps/forandroid

/usr/include/machine/types.h:37:10: fatal error: 'arm/types.h' file not found

I have spent half a day killing the error. I'm really bored and teared.
The project is converting iPhone App to Android apk by Stella SDK.
The IDE is xCode 4.6.
CompileC build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/Objects-normal/x86_64/main.o main.m normal x86_64 objective-c com.yeecco.compilers.android.clang.1.0
cd /Users/anna/samples/GLSprite
setenv LANG en_US.US-ASCII
/opt/StellaSDK/bin/android-clang -x objective-c -arch x86_64 -fmessage-length=0 -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mmacosx-version-min=10.8 -g -Wno-sign-conversion -I/Users/anna/samples/GLSprite/build-arm-google-android/Debug/include -I/opt/StellaSDK/arm-google-android/usr/include -I/opt/StellaSDK/arm-google-android/System/Library/Frameworks/cocos2d.framework/Headers -I/opt/StellaSDK/arm-google-android/System/Library/Frameworks/StellaMedia.framework/Headers -I/opt/StellaSDK/arm-google-android/System/Library/Frameworks/StellaStore.framework/Headers -I/Users/anna/samples/GLSprite/build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/DerivedSources/x86_64 -I/Users/anna/samples/GLSprite/build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/DerivedSources -F/Users/anna/samples/GLSprite/build-arm-google-android/Debug -F/opt/StellaSDK/arm-google-android/System/Library/Frameworks -stella_target arm-google-android -D__STELLA_NANDROID -D__STELLA_VERSION_MAX_ALLOWED -MMD -MT dependencies -MF /Users/anna/samples/GLSprite/build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/Objects-normal/x86_64/main.d -c /Users/anna/samples/GLSprite/main.m -o /Users/anna/samples/GLSprite/build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/Objects-normal/x86_64/main.o
warning: unknown warning option '-Wreceiver-is-weak' [-Wunknown-warning-option]
warning: unknown warning option '-Wint-conversion' [-Wunknown-warning-option]
warning: unknown warning option '-Wenum-conversion' [-Wunknown-warning-option]
In file included from /Users/anna/samples/GLSprite/main.m:49:
In file included from /opt/StellaSDK/arm-google-android/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:17:
In file included from /opt/StellaSDK/arm-google-android/System/Library/Frameworks/StellaKit.framework/Headers/StellaKit.h:7:
In file included from /opt/StellaSDK/arm-google-android/System/Library/Frameworks/StellaKit.framework/Headers/SVAcceleration.h:5:
In file included from /opt/StellaSDK/arm-google-android/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:11:
In file included from /usr/include/sys/types.h:78:
/usr/include/machine/types.h:37:10: fatal error: 'arm/types.h' file not found
#include "arm/types.h"
^
3 warnings and 1 error generated.
Command /opt/StellaSDK/bin/android-clang failed with exit code 1
The error message is shown because the compiler is looking for types.h in arm folder. If you could provide the file, the compiler will not show this error and continue. Check the documentation of StellaSDK, they should have a "guide" on how to cross compile

error linking to libgcc.a when cross-compiling for Android, but symbols exists?

I am trying to cross-compile a very simple program for Android that worked with android-ndk-r6b and prior, but does not work on android-ndk-r7 and newer:
int main() {
;
return 0;
}
I was able to do so using an "agcc" script on an older version of Android that can be found here. I'm sincerely not trying to use an Android.mk file to build this. I know I can, but this is part of something much larger I'm working on. So take it for face-value that I am trying to cross-compile this in a different way.
Anyway, I try to build and get:
$ arm-eabi-gcc -o test test.c
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: warning: /tmp/cc00QD3x.o uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
/tmp/cc00QD3x.o:(.ARM.exidx.text.main+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
collect2: ld returned 1 exit status
So, the key error is the undefined reference to __aeabi_unwind_cpp_pr0.
After doing some digging, this symbol is in libgcc.a which I am linking to:
$ arm-eabi-nm /home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/lib/gcc/arm-eabi/4.4.3/libgcc.a | grep __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr0
00000590 T __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr0
U __aeabi_unwind_cpp_pr0
It has a 'T' which tells me that it is in the code somewhere, right?
Here is the verbose output of arm-eabi-gcc which shows I am in fact linking to this library:
Using built-in specs.
Target: arm-eabi
Configured with: /home/jingyu/projects/gcc/android-toolchainsrc/build/../gcc/gcc-4.4.3/configure --prefix=/usr/local --target=arm-eabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/home/jingyu/projects/gcc/toolchain_build/obj/temp-install --with-mpfr=/home/jingyu/projects/gcc/toolchain_build/obj/temp-install --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --with-abi=aapcs --with-gcc-version=4.4.3 --with-binutils-version=2.19 --with-gmp-version=4.2.4 --with-mpfr-version=2.4.1 --with-gdb-version=7.1.x --with-arch=armv5te --with-multilib-list=mandroid --with-sysroot=/usr/local/google/home/android/cupcake_rel_root --program-transform-name='s&^&arm-eabi-&'
Thread model: single
gcc version 4.4.3 (GCC)
COLLECT_GCC_OPTIONS='-o' 'test' '-I/home/gnychis/Documents/android/os/system/core/include' '-I/home/gnychis/Documents/android/os/hardware/libhardware/include' '-I/home/gnychis/Documents/android/os/hardware/ril/include' '-I/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/include' '-I/home/gnychis/Documents/android/os/dalvik/libnativehelper/include' '-I/home/gnychis/Documents/android/os/frameworks/base/include' '-I/home/gnychis/Documents/android/os/external/skia/include' '-I/home/gnychis/Documents/android/os/out/target/product/generic/obj/include' '-I/home/gnychis/Documents/android/os/bionic/libc/arch-arm/include' '-I/home/gnychis/Documents/android/os/bionic/libc/include' '-I/home/gnychis/Documents/android/os/bionic/libstdc++/include' '-I/home/gnychis/Documents/android/os/bionic/libc/kernel/common' '-I/home/gnychis/Documents/android/os/bionic/libc/kernel/arch-arm' '-I/home/gnychis/Documents/android/os/bionic/libm/include' '-I/home/gnychis/Documents/android/os/bionic/libm/include/arch/arm' '-I/home/gnychis/Documents/android/os/bionic/libthread_db/include' '-I/home/gnychis/Documents/android/os/bionic/libm/arm' '-I/home/gnychis/Documents/android/os/bionic/libm' '-I/home/gnychis/Documents/android/os/out/target/product/generic/obj/SHARED_LIBRARIES/libm_intermediates' '-D__ARM_ARCH_5__' '-D__ARM_ARCH_5T__' '-D__ARM_ARCH_5E__' '-D__ARM_ARCH_5TE__' '-DANDROID' '-DSK_RELEASE' '-DNDEBUG' '-UDEBUG' '-march=armv5te' '-mtune=xscale' '-msoft-float' '-mthumb-interwork' '-fpic' '-fno-exceptions' '-ffunction-sections' '-funwind-tables' '-fstack-protector' '-fmessage-length=0' '-Bdynamic' '-L/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib' '-nostdlib' '-v' '-mfpu=vfp' '-mabi=aapcs'
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../libexec/gcc/arm-eabi/4.4.3/cc1 -quiet -v -I/home/gnychis/Documents/android/os/system/core/include -I/home/gnychis/Documents/android/os/hardware/libhardware/include -I/home/gnychis/Documents/android/os/hardware/ril/include -I/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/include -I/home/gnychis/Documents/android/os/dalvik/libnativehelper/include -I/home/gnychis/Documents/android/os/frameworks/base/include -I/home/gnychis/Documents/android/os/external/skia/include -I/home/gnychis/Documents/android/os/out/target/product/generic/obj/include -I/home/gnychis/Documents/android/os/bionic/libc/arch-arm/include -I/home/gnychis/Documents/android/os/bionic/libc/include -I/home/gnychis/Documents/android/os/bionic/libstdc++/include -I/home/gnychis/Documents/android/os/bionic/libc/kernel/common -I/home/gnychis/Documents/android/os/bionic/libc/kernel/arch-arm -I/home/gnychis/Documents/android/os/bionic/libm/include -I/home/gnychis/Documents/android/os/bionic/libm/include/arch/arm -I/home/gnychis/Documents/android/os/bionic/libthread_db/include -I/home/gnychis/Documents/android/os/bionic/libm/arm -I/home/gnychis/Documents/android/os/bionic/libm -I/home/gnychis/Documents/android/os/out/target/product/generic/obj/SHARED_LIBRARIES/libm_intermediates -iprefix /home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/ -D__USES_INITFINI__ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -UDEBUG test.c -quiet -dumpbase test.c -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -mfpu=vfp -mabi=aapcs -auxbase test -version -fpic -fno-exceptions -ffunction-sections -funwind-tables -fstack-protector -fmessage-length=0 -o /tmp/ccIIp1N2.s
GNU C (GCC) version 4.4.3 (arm-eabi)
compiled by GNU C version 4.2.4 (Ubuntu 4.2.4-1ubuntu4), GMP version 4.2.4, MPFR version 2.4.1.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128206
ignoring nonexistent directory "/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/include"
ignoring nonexistent directory "/usr/local/google/home/android/cupcake_rel_root/usr/local/include"
ignoring duplicate directory "/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/../../lib/gcc/arm-eabi/4.4.3/include"
ignoring duplicate directory "/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/../../lib/gcc/arm-eabi/4.4.3/include-fixed"
ignoring nonexistent directory "/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/../../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/include"
ignoring nonexistent directory "/usr/local/google/home/android/cupcake_rel_root/usr/include"
ignoring nonexistent directory "/home/gnychis/Documents/android/os/out/target/product/generic/obj/include"
ignoring nonexistent directory "/home/gnychis/Documents/android/os/bionic/libm/include/arch/arm"
ignoring nonexistent directory "/home/gnychis/Documents/android/os/out/target/product/generic/obj/SHARED_LIBRARIES/libm_intermediates"
#include "..." search starts here:
#include <...> search starts here:
/home/gnychis/Documents/android/os/system/core/include
/home/gnychis/Documents/android/os/hardware/libhardware/include
/home/gnychis/Documents/android/os/hardware/ril/include
/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/include
/home/gnychis/Documents/android/os/dalvik/libnativehelper/include
/home/gnychis/Documents/android/os/frameworks/base/include
/home/gnychis/Documents/android/os/external/skia/include
/home/gnychis/Documents/android/os/bionic/libc/arch-arm/include
/home/gnychis/Documents/android/os/bionic/libc/include
/home/gnychis/Documents/android/os/bionic/libstdc++/include
/home/gnychis/Documents/android/os/bionic/libc/kernel/common
/home/gnychis/Documents/android/os/bionic/libc/kernel/arch-arm
/home/gnychis/Documents/android/os/bionic/libm/include
/home/gnychis/Documents/android/os/bionic/libthread_db/include
/home/gnychis/Documents/android/os/bionic/libm/arm
/home/gnychis/Documents/android/os/bionic/libm
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/include
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/include-fixed
End of search list.
GNU C (GCC) version 4.4.3 (arm-eabi)
compiled by GNU C version 4.2.4 (Ubuntu 4.2.4-1ubuntu4), GMP version 4.2.4, MPFR version 2.4.1.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128206
Compiler executable checksum: c575b4a30c8a516a84cf6e49f2cb23d1
COLLECT_GCC_OPTIONS='-o' 'test' '-I/home/gnychis/Documents/android/os/system/core/include' '-I/home/gnychis/Documents/android/os/hardware/libhardware/include' '-I/home/gnychis/Documents/android/os/hardware/ril/include' '-I/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/include' '-I/home/gnychis/Documents/android/os/dalvik/libnativehelper/include' '-I/home/gnychis/Documents/android/os/frameworks/base/include' '-I/home/gnychis/Documents/android/os/external/skia/include' '-I/home/gnychis/Documents/android/os/out/target/product/generic/obj/include' '-I/home/gnychis/Documents/android/os/bionic/libc/arch-arm/include' '-I/home/gnychis/Documents/android/os/bionic/libc/include' '-I/home/gnychis/Documents/android/os/bionic/libstdc++/include' '-I/home/gnychis/Documents/android/os/bionic/libc/kernel/common' '-I/home/gnychis/Documents/android/os/bionic/libc/kernel/arch-arm' '-I/home/gnychis/Documents/android/os/bionic/libm/include' '-I/home/gnychis/Documents/android/os/bionic/libm/include/arch/arm' '-I/home/gnychis/Documents/android/os/bionic/libthread_db/include' '-I/home/gnychis/Documents/android/os/bionic/libm/arm' '-I/home/gnychis/Documents/android/os/bionic/libm' '-I/home/gnychis/Documents/android/os/out/target/product/generic/obj/SHARED_LIBRARIES/libm_intermediates' '-D__ARM_ARCH_5__' '-D__ARM_ARCH_5T__' '-D__ARM_ARCH_5E__' '-D__ARM_ARCH_5TE__' '-DANDROID' '-DSK_RELEASE' '-DNDEBUG' '-UDEBUG' '-march=armv5te' '-mtune=xscale' '-msoft-float' '-mthumb-interwork' '-fpic' '-fno-exceptions' '-ffunction-sections' '-funwind-tables' '-fstack-protector' '-fmessage-length=0' '-Bdynamic' '-L/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib' '-nostdlib' '-v' '-mfpu=vfp' '-mabi=aapcs'
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/as -v -I/home/gnychis/Documents/android/os/system/core/include -I/home/gnychis/Documents/android/os/hardware/libhardware/include -I/home/gnychis/Documents/android/os/hardware/ril/include -I/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/include -I/home/gnychis/Documents/android/os/dalvik/libnativehelper/include -I/home/gnychis/Documents/android/os/frameworks/base/include -I/home/gnychis/Documents/android/os/external/skia/include -I/home/gnychis/Documents/android/os/out/target/product/generic/obj/include -I/home/gnychis/Documents/android/os/bionic/libc/arch-arm/include -I/home/gnychis/Documents/android/os/bionic/libc/include -I/home/gnychis/Documents/android/os/bionic/libstdc++/include -I/home/gnychis/Documents/android/os/bionic/libc/kernel/common -I/home/gnychis/Documents/android/os/bionic/libc/kernel/arch-arm -I/home/gnychis/Documents/android/os/bionic/libm/include -I/home/gnychis/Documents/android/os/bionic/libm/include/arch/arm -I/home/gnychis/Documents/android/os/bionic/libthread_db/include -I/home/gnychis/Documents/android/os/bionic/libm/arm -I/home/gnychis/Documents/android/os/bionic/libm -I/home/gnychis/Documents/android/os/out/target/product/generic/obj/SHARED_LIBRARIES/libm_intermediates -march=armv5te -mthumb-interwork -mfloat-abi=soft -mfpu=vfp -meabi=5 -o /tmp/ccGAKjxX.o /tmp/ccIIp1N2.s
GNU assembler version 2.19 (arm-eabi) using BFD version (GNU Binutils) 2.19
COMPILER_PATH=/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../libexec/gcc/arm-eabi/4.4.3/:/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../libexec/gcc/:/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/
LIBRARY_PATH=/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/:/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/:/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/lib/
COLLECT_GCC_OPTIONS='-o' 'test' '-I/home/gnychis/Documents/android/os/system/core/include' '-I/home/gnychis/Documents/android/os/hardware/libhardware/include' '-I/home/gnychis/Documents/android/os/hardware/ril/include' '-I/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/include' '-I/home/gnychis/Documents/android/os/dalvik/libnativehelper/include' '-I/home/gnychis/Documents/android/os/frameworks/base/include' '-I/home/gnychis/Documents/android/os/external/skia/include' '-I/home/gnychis/Documents/android/os/out/target/product/generic/obj/include' '-I/home/gnychis/Documents/android/os/bionic/libc/arch-arm/include' '-I/home/gnychis/Documents/android/os/bionic/libc/include' '-I/home/gnychis/Documents/android/os/bionic/libstdc++/include' '-I/home/gnychis/Documents/android/os/bionic/libc/kernel/common' '-I/home/gnychis/Documents/android/os/bionic/libc/kernel/arch-arm' '-I/home/gnychis/Documents/android/os/bionic/libm/include' '-I/home/gnychis/Documents/android/os/bionic/libm/include/arch/arm' '-I/home/gnychis/Documents/android/os/bionic/libthread_db/include' '-I/home/gnychis/Documents/android/os/bionic/libm/arm' '-I/home/gnychis/Documents/android/os/bionic/libm' '-I/home/gnychis/Documents/android/os/out/target/product/generic/obj/SHARED_LIBRARIES/libm_intermediates' '-D__ARM_ARCH_5__' '-D__ARM_ARCH_5T__' '-D__ARM_ARCH_5E__' '-D__ARM_ARCH_5TE__' '-DANDROID' '-DSK_RELEASE' '-DNDEBUG' '-UDEBUG' '-march=armv5te' '-mtune=xscale' '-msoft-float' '-mthumb-interwork' '-fpic' '-fno-exceptions' '-ffunction-sections' '-funwind-tables' '-fstack-protector' '-fmessage-length=0' '-Bdynamic' '-L/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib' '-nostdlib' '-v' '-mfpu=vfp' '-mabi=aapcs'
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../libexec/gcc/arm-eabi/4.4.3/collect2 --sysroot=/usr/local/google/home/android/cupcake_rel_root -X -o test -L/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib -L/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3 -L/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc -L/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/lib -T /home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/arm-eabi/lib/ldscripts/armelf.x -dynamic-linker /system/bin/linker --gc-sections -z nocopyreloc --no-undefined -rpath-link=/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib /home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib/crtend_android.o /home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib/crtbegin_dynamic.o /home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/lib32/libiberty.a /home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/lib/gcc/arm-eabi/4.4.3/libgcc.a -lc -lm /tmp/ccGAKjxX.o
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: warning: /tmp/ccGAKjxX.o uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
/tmp/ccGAKjxX.o:(.ARM.exidx.text.main+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
collect2: ld returned 1 exit status
So I'm just a bit unsure why I am getting this undefined reference. I have used this same method of cross-compiling with a slightly different version of Android and had no issue.
Does anything stand out to anyone?
EDIT: The actual command generated is the following:
arm-eabi-gcc -o test -I/home/gnychis/Documents/android/os/system/core/include -I/home/gnychis/Documents/android/os/hardware/libhardware/include -I/home/gnychis/Documents/android/os/hardware/ril/include -I/home/gnychis/Documents/android/os/dalvik/libnativehelper/include -I/home/gnychis/Documents/android/os/frameworks/base/include -I/home/gnychis/Documents/android/os/external/skia/include -I/home/gnychis/Documents/android/os/out/target/product/generic/obj/include -I/home/gnychis/Documents/android/os/bionic/libc/arch-arm/include -I/home/gnychis/Documents/android/os/bionic/libc/include -I/home/gnychis/Documents/android/os/bionic/libstdc++/include -I/home/gnychis/Documents/android/os/bionic/libc/kernel/common -I/home/gnychis/Documents/android/os/bionic/libc/kernel/arch-arm -I/home/gnychis/Documents/android/os/bionic/libm/include -I/home/gnychis/Documents/android/os/bionic/libm/include/arch/arm -I/home/gnychis/Documents/android/os/bionic/libthread_db/include -I/home/gnychis/Documents/android/os/bionic/libm/arm -I/home/gnychis/Documents/android/os/bionic/libm -I/home/gnychis/Documents/android/os/out/target/product/generic/obj/SHARED_LIBRARIES/libm_intermediates -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -include /home/gnychis/Documents/android/os/system/core/include/arch/linux-arm/AndroidConfig.h -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fstack-protector -fmessage-length=0 -Bdynamic -Wl,-T,/home/gnychis/Documents/android/os/build/core/armelf.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,-rpath-link=/home/gnychis/Documents/android/os/../android-ndk-r7b/platforms/android-9/arch-arm/usr/lib -L/home/gnychis/Documents/android/os/../android-ndk-r7b/platforms/android-9/arch-arm/usr/lib -nostdlib /home/gnychis/Documents/android/os/../android-ndk-r7b/platforms/android-9/arch-arm/usr/lib/crtend_android.o /home/gnychis/Documents/android/os/../android-ndk-r7b/platforms/android-9/arch-arm/usr/lib/crtbegin_dynamic.o /home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/lib/gcc/arm-eabi/4.4.3/libgcc.a -lc -lm test.c
Here's your link like, broken out into multiple lines for clarity:
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../libexec/gcc/arm-eabi/4.4.3/collect2 \
--sysroot=/usr/local/google/home/android/cupcake_rel_root \
-X \
-o test \
-L/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib \
-L/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3 \
-L/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc
-L/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/lib
-T /home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/arm-eabi/lib/ldscripts/armelf.x \
-dynamic-linker /system/bin/linker \
--gc-sections \
-z nocopyreloc \
--no-undefined \
-rpath-link=/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib \
/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib/crtend_android.o \
/home/gnychis/Documents/android/android-ndk-r7b/platforms/android-9/arch-arm/usr/lib/crtbegin_dynamic.o \
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/lib32/libiberty.a \
/home/gnychis/Documents/android/os/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/lib/gcc/arm-eabi/4.4.3/libgcc.a \
-lc \
-lm \
/tmp/ccGAKjxX.o
As you can see, your own object file (the temporary one) is the very last item on the command line. This is just wrong. It needs to be before the libraries, at least, if it is to link correctly.
Basically, your agcc script is passing -nostdlib (which says that you know better) and then passing the libraries manually, but doing it in completely the wrong order. If you fix this, all should be well.
Link order is very important. Objects and libraries that provide symbols must be linked after objects and libraries that require symbols.
There were certain versions of the tools that could tolerate bad ordering, but I think that was a bug, or mis-feature, because newer toolchains cannot, and should not. Presumably this script was written for one of those.
Where to find: __aeabi_unwind_cpp_pr0 and other mysterious, undefined functions
(I had a similar problem error to what you describe, but found a different solution, that may be helpful to you or others)
I found 'libgccunwind.a' library in the Google NDK package which defines a number of these mysterious functions (they are functions referenced by libc.a and other libraries in the NDK package, but not defined in a standard library) I found them defined in a libgccunwind.a library in:
\sources\android\gccunwind\libs\armeabi
NM shows that they are defined in that lib from an 'unwind-arm.o' file:
nm libgccunwind.a
unwind-arm.o:
U _GLOBAL_OFFSET_TABLE_
00000cf8 T _Unwind_Complete
00000cfc T _Unwind_DeleteException
00000ba4 T _Unwind_GetCFA
00000408 t _Unwind_GetGR
00000474 t _Unwind_SetGR
000003c4 T _Unwind_VRS_Get
0000084c T _Unwind_VRS_Pop
00000430 T _Unwind_VRS_Set
00000844 T __aeabi_unwind_cpp_pr0
0000083c W __aeabi_unwind_cpp_pr1
00000834 W __aeabi_unwind_cpp_pr2
w __cxa_begin_cleanup
w __cxa_call_unexpected
w __cxa_type_match
U __exidx_end
U __exidx_start
00000d1c T __gnu_Unwind_Backtrace
w __gnu_Unwind_Find_exidx
Independant of the libgccunwind.a above, I searched for __aeabi_unwind_cpp_pr0 and unwind-arm.c and unwind.c, and found various c source, for example:
http://lxr.free-electrons.com/source/arch/arm/kernel/unwind.c?a=arm
http://opensource.apple.com/source/gcc/gcc-5646/gcc/config/arm/unwind-arm.c
These programs seem to be derived from a similar source. My guess is that these 'unwind_cpp' (and related functions) are called by the functions in libc.a when a function returns or on certain events so that these functions can perform some debugging or tracing operation.
In any event, adding that directory in a -L linker option and -lgccunwind linker option (after the -lc linker option) allowed the linker to find those 'undefined' functions -- and let me get to the next problem I have in cross compiling to ARM systems.

Categories

Resources