Skip to content

Failing to cross-compile in Linux with Android NDK #2

Description

@halfonsog

Hello,
The code compiles perfectly in Linux (Ubuntu 20.04.2 LTS 64), but it fails when trying to compile it for Android.
Your help is highly appreciated

I used this procedure:

$ git clone 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   

When comparing configure results (linux vs android) these are the main differences:

    checking for GNU libc compatible malloc... yes
    checking for stdlib.h... (cached) yes
    checking for GNU libc compatible realloc... yes
    checking for working strtod... yes
    checking for pow... yes
    checking for GNU libc compatible malloc... no
    checking for stdlib.h... (cached) yes
    checking for GNU libc compatible realloc... no
    checking for working strtod... no
    checking for pow... no
    checking for pow in -lm... yes

make's output is hereafter:

Making all in src
make[1]: Entering directory '/home/hery/dev/iphreeqc-3.7.0-15749/output/src'
  CXX      CSelectedOutput.lo
  CXX      IPhreeqc.lo
  CXX      IPhreeqc_interface_F.lo
  CXX      IPhreeqcLib.lo
  CXX      phreeqcpp/cvdense.lo
  CXX      phreeqcpp/cvode.lo
../../src/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
        ^
  CXX      phreeqcpp/cxxKinetics.lo
1 warning generated.
../../src/phreeqcpp/cvode.cpp:77: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/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
../../src/phreeqcpp/inverse.cpp:5109: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)
                    ~ ^  ~~~
../../src/phreeqcpp/inverse.cpp:5133: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)
                    ~ ^  ~~~
  CXX      phreeqcpp/ISolution.lo
  CXX      phreeqcpp/ISolutionComp.lo
  CXX      phreeqcpp/isotopes.lo
2 warnings generated.
  CXX      phreeqcpp/kinetics.lo
  CXX      phreeqcpp/KineticsComp.lo
  CXX      phreeqcpp/mainsubs.lo
  CXX      phreeqcpp/model.lo
  CXX      phreeqcpp/NameDouble.lo
../../src/phreeqcpp/model.cpp:3126:8: error: no member named 'isfinite' in namespace 'std'; did you mean 'finite'?
                if (!PHR_ISFINITE((double) delta[i]))
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/phreeqcpp/Phreeqc.h:1839: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__;
    ^
../../src/phreeqcpp/model.cpp:3321:8: error: no member named 'isfinite' in namespace 'std'; did you mean 'finite'?
                if (!PHR_ISFINITE((double) delta[i]))
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/phreeqcpp/Phreeqc.h:1839: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__;
    ^
../../src/phreeqcpp/model.cpp:4755:10: error: no member named 'isfinite' in namespace 'std'; did you mean 'finite'?
                                if (!PHR_ISFINITE((double) f))
                                     ^~~~~~~~~~~~~~~~~~~~~~~~
../../src/phreeqcpp/Phreeqc.h:1839: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__;
    ^
../../src/phreeqcpp/model.cpp:4812: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:1839: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__;
    ^
../../src/phreeqcpp/model.cpp:5479:10: error: no member named 'isfinite' in namespace 'std'; did you mean 'finite'?
                                if (!PHR_ISFINITE(my_array[(size_t)j * (count_unknowns + 1) + (size_t)i]))
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/phreeqcpp/Phreeqc.h:1839: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:983: phreeqcpp/model.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/hery/dev/iphreeqc/output/src'
make: *** [Makefile:401: all-recursive] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions