簡體   English   中英

無法使用 Android NDK 交叉編譯 C++ 庫

[英]Failing to cross-compile c++ library with Android NDK

該庫在 linux (Ubuntu 20.04.2 LTS 64) 中完美編譯,但在嘗試為 android 編譯時失敗。 使用流程:

$ git https://github.com/ufz/iphreeqc 
$ cd iphreeqc 
$ mkdir output 
$ export ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/22.1.7171670 
$ PATH=$PATH:$ANDROID_NDK 
$ export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64 
$ export TARGET=armv7a-linux-androideabi 
$ export API=21 
$ export AR=$TOOLCHAIN/bin/llvm-ar 
$ export CC=$TOOLCHAIN/bin/$TARGET$API-clang 
$ export AS=$CC 
$ export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++ 
$ export LD=$TOOLCHAIN/bin/ld 
$ export RANLIB=$TOOLCHAIN/bin/llvm-ranlib 
$ export STRIP=$TOOLCHAIN/bin/llvm-strip 
$ ./configure --prefix=$(pwd)/output --host $TARGET --disable-shared 
$ make       

此后輸出和錯誤。 任何幫助表示高度贊賞

Making all in src
    make[1]: Entering directory '/home/hery/Downloads/iphreeqc/src'
      CXX      CSelectedOutput.lo
      CXX      IPhreeqc.lo
      CXX      IPhreeqc_interface_F.lo
      CXX      IPhreeqcLib.lo
      CXX      phreeqcpp/advection.lo
      CXX      phreeqcpp/basicsubs.lo
      CXX      phreeqcpp/cl1.lo
      CXX      phreeqcpp/common/Parser.lo
      CXX      phreeqcpp/common/PHRQ_base.lo
      CXX      phreeqcpp/common/PHRQ_io.lo
      CXX      phreeqcpp/common/Utils.lo
      CXX      phreeqcpp/cvdense.lo
    phreeqcpp/cvdense.cpp:76:9: warning: 'malloc' macro redefined [-Wmacro-redefined]
    #define malloc PHRQ_malloc
            ^
    <command line>:31:9: note: previous definition is here
    #define malloc rpl_malloc
            ^
    1 warning generated.
      CXX      phreeqcpp/cvode.lo
    phreeqcpp/cvode.cpp:76:9: warning: 'malloc' macro redefined [-Wmacro-redefined]
    #define malloc MACHENV_MALLOC PHRQ_malloc
            ^
    <command line>:31:9: note: previous definition is here
    #define malloc rpl_malloc
            ^
    1 warning generated.
      CXX      phreeqcpp/cxxKinetics.lo
      CXX      phreeqcpp/cxxMix.lo
      CXX      phreeqcpp/dense.lo
      CXX      phreeqcpp/Dictionary.lo
      CXX      phreeqcpp/dumper.lo
      CXX      phreeqcpp/Exchange.lo
      CXX      phreeqcpp/ExchComp.lo
      CXX      phreeqcpp/GasComp.lo
      CXX      phreeqcpp/gases.lo
      CXX      phreeqcpp/GasPhase.lo
      CXX      phreeqcpp/input.lo
      CXX      phreeqcpp/integrate.lo
      CXX      phreeqcpp/inverse.lo
    phreeqcpp/inverse.cpp:5319:9: warning: result of comparison of constant -1 with expression of type 'char' is always true [-Wtautological-constant-out-of-range-compare]
                    if (c != EOF && c != '\n' && i != MAX_LINE)
                        ~ ^  ~~~
    phreeqcpp/inverse.cpp:5343:9: warning: result of comparison of constant -1 with expression of type 'char' is always false [-Wtautological-constant-out-of-range-compare]
                    if (c == EOF)
                        ~ ^  ~~~
    2 warnings generated.
      CXX      phreeqcpp/ISolution.lo
      CXX      phreeqcpp/ISolutionComp.lo
      CXX      phreeqcpp/isotopes.lo
      CXX      phreeqcpp/kinetics.lo
      CXX      phreeqcpp/KineticsComp.lo
      CXX      phreeqcpp/mainsubs.lo
      CXX      phreeqcpp/model.lo
    phreeqcpp/model.cpp:3364:8: error: no member named 'isfinite' in namespace 'std'; did you mean 'finite'?
                    if (!PHR_ISFINITE((double) delta[i]))
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/phreeqcpp/Phreeqc.h:2041:29: note: expanded from macro 'PHR_ISFINITE'
    #    define PHR_ISFINITE(x) std::isfinite(x)
                                ^~~~~
    /home/hery/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/math.h:373:5: note: 'finite' declared here
    int finite(double __x) __attribute_const__;
        ^
    phreeqcpp/model.cpp:3559:8: error: no member named 'isfinite' in namespace 'std'; did you mean 'finite'?
                    if (!PHR_ISFINITE((double) delta[i]))
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/phreeqcpp/Phreeqc.h:2041:29: note: expanded from macro 'PHR_ISFINITE'
    #    define PHR_ISFINITE(x) std::isfinite(x)
                                ^~~~~
    /home/hery/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/math.h:373:5: note: 'finite' declared here
    int finite(double __x) __attribute_const__;
        ^
    phreeqcpp/model.cpp:4990:10: error: no member named 'isfinite' in namespace 'std'; did you mean 'finite'?
                                    if (!PHR_ISFINITE((double) f))
                                         ^~~~~~~~~~~~~~~~~~~~~~~~
    ../src/phreeqcpp/Phreeqc.h:2041:29: note: expanded from macro 'PHR_ISFINITE'
    #    define PHR_ISFINITE(x) std::isfinite(x)
                                ^~~~~
    /home/hery/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/math.h:373:5: note: 'finite' declared here
    int finite(double __x) __attribute_const__;
        ^
    phreeqcpp/model.cpp:5050:12: error: no member named 'isfinite' in namespace 'std'; did you mean 'finite'?
                                                            if (PHR_ISFINITE((double) d1) /*&& d1 < 5.0*/)
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/phreeqcpp/Phreeqc.h:2041:29: note: expanded from macro 'PHR_ISFINITE'
    #    define PHR_ISFINITE(x) std::isfinite(x)
                                ^~~~~
    /home/hery/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/math.h:373:5: note: 'finite' declared here
    int finite(double __x) __attribute_const__;
        ^
    phreeqcpp/model.cpp:5733:10: error: no member named 'isfinite' in namespace 'std'; did you mean 'finite'?
                                    if (!PHR_ISFINITE(my_array[j * (count_unknowns + 1) + i]))
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/phreeqcpp/Phreeqc.h:2041:29: note: expanded from macro 'PHR_ISFINITE'
    #    define PHR_ISFINITE(x) std::isfinite(x)
                                ^~~~~
    /home/hery/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/math.h:373:5: note: 'finite' declared here
    int finite(double __x) __attribute_const__;
        ^
    5 errors generated.
    make[1]: *** [Makefile:1056: phreeqcpp/model.lo] Error 1
    make[1]: Leaving directory '/home/hery/Downloads/iphreeqc/src'
    make: *** [Makefile:400: all-recursive] Error 1

編輯src/phreeqcpp/Phreeqc.h以在#include <math.h>下方添加#include <cmath>使其在此處編譯。

請提前支付並將其作為拉取請求提交給項目!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM