使用g ++

时间:2018-01-30 09:41:20

标签: android gcc android-ndk cross-compiling

我试图用arm-linux-androideabi-g ++工具从linux编译.cc文件。它包括#include<algorithm> 当我尝试编译它时,我得到了这个错误:
fatal error: algorithm: No such file or directory 我认为我应该使用-I标志将库标题指向编译器,但是我不确定它应该是什么目录。
有没有人知道如何编译它? 我试着在ndk包中查找头文件:

./toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/5.0.300080/include/cuda_wrappers/algorithm
./toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/5.0/include/cuda_wrappers/algorithm
./sources/cxx-stl/llvm-libc++/include/algorithm
./sources/cxx-stl/llvm-libc++/include/experimental/algorithm
./sources/cxx-stl/stlport/stlport/algorithm
./sources/cxx-stl/gnu-libstdc++/4.9/include/algorithm
./sources/cxx-stl/gnu-libstdc++/4.9/include/ext/algorithm
./sources/cxx-stl/gnu-libstdc++/4.9/include/parallel/algorithm

我尝试了这两个目录:

arm-linux-androideabi-g++ hello.cc -I/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include
In file included from /ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/algorithm:60:0,
     from hello.cc:1:
     /ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/utility:68:28:  
     fatal error: bits/c++config.h: No such file or directory
compilation terminated.

arm-linux-androideabi-g++ hello.cc -I/ndk/sources/cxx-stl/llvm-libc++/include/
In file included from /ndk/sources/cxx-stl/llvm-libc++/include/exception:82:0,
                 from /ndk/sources/cxx-stl/llvm-libc++/include/typeinfo:61,
                 from /ndk/sources/cxx-stl/llvm-libc++/include/memory:644,
                 from /ndk/sources/cxx-stl/llvm-libc++/include/algorithm:643,
                 from hello.cc:1:
/ndk/sources/cxx-stl/llvm-libc++/include/cstdlib:114:9: error: '::strtold' has not been declared
/ndk/sources/cxx-stl/llvm-libc++/include/cstdlib:132:9: error: '::_Exit' has not been declared

我尝试做的是为android构建protobuf库。构建失败,缺少算法文件。这是我试图将其分解。

1 个答案:

答案 0 :(得分:1)

您不能直接使用NDK调用编译器(虽然修复了r19的路线图)。使用standalone toolchain或其中一个受支持的构建系统。