Reputation: 10109
I am compiling a simple program with the Android NDK Linux build on Ubuntu Linux 10.0.4.
//no includes!!!
int main()
{
int a = 1, b = 2, c = -1;
return a + b + c - ( a + b + c);
}
When I run this bash script for gcc,
bin='/media/sdb/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin'
rm -r ./obj/*.*
$bin/arm-linux-androideabi-gcc -c ./main.c -o ./obj/main.o
$bin/arm-linux-androideabi-gcc ./obj/main.o -o ./obj/main.exe
the output of gcc gives a message from ld
(arm-linux-androideabi-ld) that it terminated as 7 (second comma-delimited is ARM) signal.
This simple program won't even compile on Linux, please help!
Upvotes: 1
Views: 1152
Reputation: 27230
I have installed static tool chain in ubuntu 12.4
sudo apt-get install gcc-arm-linux-gnueabi // install this toolchain
arm-linux-gnueabi-gcc -static -o main.exe main.c // this way compile ur binary
copy through adb in android machine and run
./main.exe
this works in my android mobile.
Edit:
for 10.04
sudo add-apt-repository ppa:linaro-maintainers/toolchain
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabi
Edit2: Its static compilation here it doesnt use bionic code and it include libraries by copying them into the ELF.
If you want to dynamic compilation or want to depend on bionic code then use
$NDK/docs/STANDALONE-TOOLCHAIN.html https://android.googlesource.com/platform/ndk/+/master/docs/STANDALONE-TOOLCHAIN.html
Upvotes: 1