【问题标题】:Compiling for android from linux with g++使用 g++ 从 linux 编译 android
【发布时间】:2018-07-09 03:37:53
【问题描述】:

我正在尝试使用 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 库。构建失败,缺少算法文件。这是我试图打破它。

【问题讨论】:

    标签: android gcc android-ndk cross-compiling


    【解决方案1】:

    您不能直接使用 NDK 调用编译器(尽管在 r19 的路线图中修复了该问题)。使用standalone toolchain 或受支持的构建系统之一。

    【讨论】:

      猜你喜欢
      • 2013-07-21
      • 1970-01-01
      • 1970-01-01
      • 2023-01-27
      • 1970-01-01
      • 2014-03-14
      • 2021-10-27
      • 1970-01-01
      • 2015-02-16
      相关资源
      最近更新 更多