5

I have arm-linux-androideabi-gcc installed in my computer, but when I try to compiler even a simple hellow world, it gives error ( I am choosing not to use ndk-build ) . I just want to compile from the command line ...

#include <iostream>

using namespace std;

int main (){
    return 0;
}

And I received this error:

error: iostream: No such file or directory

I have the arm-linux-androideabi-gcc in ~/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin .

I have tried including -I ~/android-ndk-r7b/platforms/android-9/arch-arm/usr

I have also tried including -lstdc++ just to see if it works but no ...

./arm-linux-androideabi-g++ -o ff first.cpp -I /home/hari/android-ndk-r7b/platforms/android-9/arch-arm/usr -lstdc++
Alvin Wong
  • 12,210
  • 5
  • 51
  • 77
solti
  • 4,339
  • 3
  • 31
  • 51
  • 1
    The problem was with make-standalone-toolchain.sh ... edit this file as this link says -->> https://android-review.googlesource.com/#/c/39878/1/build/tools/make-standalone-toolchain.sh and thank you Frohnzie for helping me figure this out .. – solti Aug 17 '12 at 07:48

3 Answers3

7

First you need to create the standalone toolchain:

make-standalone-toolchain.sh --platform=android-14 --install-dir=standalone-toolchain --ndk-dir=$ANDROID_NDK_PATH

export the PATH:

export PATH=$TOOLCH/standalone-toolchain/bin:$PATH

Then build the file:

arm-linux-androideabi-g++ -o test-new test.cpp

Note: issue using revision 8b which is the latest version of the NDK: http://code.google.com/p/android/issues/detail?id=35279

arm-linux-androideabi-g++ -o test-new test.cpp --sysroot=$TOOLCH/sysroot
-I$TOOLCH/lib/gcc/arm-linux-androideabi/4.6.x-google/include
-I$TOOLCH/lib/gcc/arm-linux-androideabi/4.6.x-google/include-fixed
-I$TOOLCH/arm-linux-androideabi/include/c++/4.6
-I$TOOLCH/arm-linux-androideabi/include/c++/4.6/arm-linux-androideabi
-I$TOOLCH/sysroot/usr/include
Frohnzie
  • 3,559
  • 1
  • 21
  • 24
  • thank you Frohnzie for the answer really appreciate it .. now arm-linux-androideabi-gcc works fine now ... i was able to compile with no problem :) – solti Jul 31 '12 at 22:04
1

Look at the error: iostream: No such file or directory

#include "iostream" should be #include #include <iostream>

Frohnzie
  • 3,559
  • 1
  • 21
  • 24
  • i did that .. stackoverflow hids the whole string iostream ( strange ... ) when i do that but in my program i do #include .. thank you for the response though .. – solti Jul 31 '12 at 19:45
0

According to http://code.google.com/p/android/issues/detail?id=35279 , this is a bug of the standalone toolchain. I think the best fix-around is ln -s $TOOLCH/arm-linux-androideabi/include/c++/4.6 $TOOLCH/arm-linux-androideabi/include/c++/4.6.x-google