I'm trying to build a single .cpp
file that includes several other files via clang for NDK.
First of all, I did that before with other files so it is not the problem that I'm doing it like this and not using ndk-build
.
Once I tried to build the library, that uses math.h, I got the bunch of weird errors claiming that math.h redefines itself:
/usr/bin/clang -fPIC -fobjc-arc -fmodules -fmodule-name=Cbgfx '-B/home/s1ddok/Documents/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin' '-I/home/s1ddok/Documents/android-ndk-r13b/sources/cxx-stl/llvm-libc++/include' '-fmodules-cache-path=/home/s1ddok/Documents/sbgfx/SwiftBGFX/.build/debug/ModuleCache' -g '-O0' -MD -MT dependencies -MF '/home/s1ddok/Documents/sbgfx/SwiftBGFX/.build/debug/Cbgfx.build/amalgamated.cpp.d' -c '/home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/amalgamated.cpp' -o '/home/s1ddok/Documents/sbgfx/SwiftBGFX/.build/debug/Cbgfx.build/amalgamated.cpp.o' -I '/home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include'
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/amalgamated.cpp:6:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include/bgfx.cpp:13:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include/bgfx_p.h:128:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include/bx/fpumath.h:12:
In file included from /home/s1ddok/Documents/android-ndk-r13b/sources/cxx-stl/llvm-libc++/include/math.h:301:
/home/s1ddok/Documents/android-ndk-r13b/platforms/android-21/arch-arm//usr/include/math.h:29:20: error: redefinition of '__infinity_un'
extern const union __infinity_un {
^
/home/s1ddok/Documents/android-ndk-r13b/platforms/android-21/arch-arm//usr/include/math.h:29:20: note: previous definition is here
extern const union __infinity_un {
^
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/amalgamated.cpp:6:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include/bgfx.cpp:13:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include/bgfx_p.h:128:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include/bx/fpumath.h:12:
In file included from /home/s1ddok/Documents/android-ndk-r13b/sources/cxx-stl/llvm-libc++/include/math.h:301:
/home/s1ddok/Documents/android-ndk-r13b/platforms/android-21/arch-arm//usr/include/math.h:34:20: error: redefinition of '__nan_un'
extern const union __nan_un {
^
/home/s1ddok/Documents/android-ndk-r13b/platforms/android-21/arch-arm//usr/include/math.h:34:20: note: previous definition is here
extern const union __nan_un {
^
I copied only two first errors, but others are all the same. The main key here is that I think there is a clash between libc++
's math.h
and sysroot
's math.h
, because the very first error is a bit diffrent from others:
In file included from /home/s1ddok/Documents/android-ndk-r13b/sources/cxx-stl/llvm-libc++/include/math.h:301: /home/s1ddok/Documents/android-ndk-r13b/platforms/android-21/arch-arm//usr/include/math.h:34:20: error: redefinition of '__nan_un'
Later below I'm also getting a bunch of such errors:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/amalgamated.cpp:6:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include/bgfx.cpp:13:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include/bgfx_p.h:128:
In file included from /home/s1ddok/Documents/sbgfx/SwiftBGFX/Sources/Cbgfx/include/bx/fpumath.h:12:
/home/s1ddok/Documents/android-ndk-r13b/sources/cxx-stl/llvm-libc++/include/math.h:526:1: error: redefinition of '__libcpp_isless'
__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
^
/home/s1ddok/Documents/android-ndk-r13b/sources/cxx-stl/llvm-libc++/include/math.h:526:1: note: previous definition is here
__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
^
claiming that libc++
redefines itself again. How do you provide both libc++
-I
flag and --sysroot
one while avoiding header clash when building for NDK
?