Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
681 views
in Technique[技术] by (71.8m points)

android - why does arm-linux-androideabi-gcc give iostream error

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++
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...