Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Android NDK libcpp include path #3641

Closed
renning22 opened this issue Aug 30, 2017 · 13 comments
Closed

Wrong Android NDK libcpp include path #3641

renning22 opened this issue Aug 30, 2017 · 13 comments
Assignees

Comments

@renning22
Copy link

If possible, provide a minimal example to reproduce the problem:

Build with --crosstool_top=@androidndk//:toolchain-libcpp, C++ headers can not be found.
I guess it's caused by wrong "-isystem" paths.

Bazel sets "external/androidndk/ndk/sources/cxx-stl/llvm-libc++/libcxx/include" but it should be "external/androidndk/ndk/sources/cxx-stl/llvm-libc++/include". (I inspected with NDK r13/r15.)

Environment info

  • Operating System:
    Ubuntu 14.04

  • Bazel version (output of bazel info release):
    0.5.2 (also tried with 0.4.5)

@aj-michael
Copy link
Contributor

This seems to have been a change between R12 and R13.

@aj-michael
Copy link
Contributor

@renning22 , can you give an example of a header that cannot be found and a full bazel command line?

@kangnak
Copy link

kangnak commented Sep 13, 2017

I have the same issue. All standard C++ headers are not found. As Ning told, I verified the include dir is set wrong in bazel-myproject/external/androidndk/BUILD.bazel. I used this command to build:

bazel build my_build_rule --cpu=armeabi-v7a --crosstool_top=@androidndk//:toolchain-libcpp --host_crosstool_top=@bazel_tools//tools/cpp:toolchain

@aj-michael
Copy link
Contributor

workaround: @androidndk//:toolchain-stlport and @androidndk//:toolchaingnu-libstdcpp are correct in bazel 0.5.4. Working on fixing @androidndk//:toolchain-libcpp now.

@Qining
Copy link

Qining commented Feb 9, 2018

Same issue here when compiling gRPC with Bazel and NDK. Using gnu-libstdcpp and stlport results into to_string is not a member of std. Any workaround available?

@etnu
Copy link

etnu commented Feb 12, 2018

gnu-libstdcpp for android doesn't implement many basic standard library features correctly. It's not even supported by android anymore as far as I know.

Consequently, it's very difficult to have shared libraries between android and other platforms until this bug is fixed, so my project is stuck using cmake just for android.

Is there a workaround that lets us use the default standard library?

@ncouro
Copy link

ncouro commented Feb 13, 2018

Same issue here, a few C++11 headers cannot be found when building using toolchain-libcpp.

I got it to build by manually changing the include paths in the build file from the androidndk repository. I've put the new build rule there: https://github.com/ncouro/bazel_ndk in case it's useful to anyone.

I could try making the changes upstream with some guidance (I'm new to Android and Bazel).

@jin jin self-assigned this Feb 13, 2018
@jin
Copy link
Member

jin commented Feb 13, 2018

@ncouro that is excellent! I have a change in progress internally for r15 support, but let me externalize that into a PR - give me some time to go through your code and see if we can get our efforts to converge.

The main NDK 16 support thread is here: #4068

@farwayer
Copy link

-stlport and -gnu-libstdcpp is not workaround in many cases...

@jin
Copy link
Member

jin commented Feb 20, 2018

Root cause: generated BUILD.bazel for r13 is incorrect.

# r12b
jingwen@jingwen:~/code/tensorflow/bazel-tensorflow/external/androidndk
$ grep -o -E "ndk/.*[^\*]\/" BUILD.bazel | xargs file | sort | uniq

# .. snip ..

ndk/platforms/android-24/arch-arm64/:                                                                      directory
ndk/platforms/android-24/arch-arm/:                                                                        directory
ndk/platforms/android-24/arch-mips64/:                                                                     directory
ndk/platforms/android-24/arch-mips/:                                                                       directory
ndk/platforms/android-24/arch-x86_64/:                                                                     directory
ndk/platforms/android-24/arch-x86/:                                                                        directory
ndk/sources/android/cpufeatures/:                                                                          directory
ndk/sources/android/support/include/:                                                                      directory
ndk/sources/cxx-stl/gabi++/include/:                                                                       directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/backward/:                                                   directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/:                                                            directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/:                                                     directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include/:                                             directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/:                                                       directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include/:                                               directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/:                                                   directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/:                                           directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/:                                                        directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/include/:                                                directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/:                                                          directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/include/:                                                  directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/:                                                        directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include/:                                                directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/:                                                           directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include/:                                                   directory
ndk/sources/cxx-stl/llvm-libc++abi/libcxxabi/include/:                                                     directory
ndk/sources/cxx-stl/llvm-libc++/libcxx/include/:                                                           directory
ndk/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/:                                                           directory
ndk/sources/cxx-stl/llvm-libc++/libs/armeabi/:                                                             directory
ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/:                                                         directory
ndk/sources/cxx-stl/llvm-libc++/libs/mips64/:                                                              directory
ndk/sources/cxx-stl/llvm-libc++/libs/mips/:                                                                directory
ndk/sources/cxx-stl/llvm-libc++/libs/x86_64/:                                                              directory
ndk/sources/cxx-stl/llvm-libc++/libs/x86/:                                                                 directory
ndk/sources/cxx-stl/stlport/libs/arm64-v8a/:                                                               directory
ndk/sources/cxx-stl/stlport/libs/armeabi/:                                                                 directory
ndk/sources/cxx-stl/stlport/libs/armeabi-v7a/:                                                             directory
ndk/sources/cxx-stl/stlport/libs/mips64/:                                                                  directory
ndk/sources/cxx-stl/stlport/libs/mips/:                                                                    directory
ndk/sources/cxx-stl/stlport/libs/x86_64/:                                                                  directory
ndk/sources/cxx-stl/stlport/libs/x86/:                                                                     directory
ndk/sources/cxx-stl/stlport/stlport/:                                                                      directory
ndk/toolchains/aarch64-linux-android-4.9/:                                                                 directory
ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/:                                       directory
ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/:                                           directory
ndk/toolchains/arm-linux-androideabi-4.9/:                                                                 directory
ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/:                                       directory
ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/:                                           directory
ndk/toolchains/llvm/:                                                                                      directory
ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/:                                                            directory
ndk/toolchains/mips64el-linux-android-4.9/:                                                                directory
ndk/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64/bin/:                                      directory
ndk/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64/:                                          directory
ndk/toolchains/mipsel-linux-android-4.9/:                                                                  directory
ndk/toolchains/mipsel-linux-android-4.9/prebuilt/linux-x86_64/bin/:                                        directory
ndk/toolchains/mipsel-linux-android-4.9/prebuilt/linux-x86_64/:                                            directory
ndk/toolchains/x86-4.9/:                                                                                   directory
ndk/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/:                                                         directory
ndk/toolchains/x86-4.9/prebuilt/linux-x86_64/:                                                             directory
ndk/toolchains/x86_64-4.9/:                                                                                directory
ndk/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/:                                                      directory
ndk/toolchains/x86_64-4.9/prebuilt/linux-x86_64/:                                                          directory

 
# r13b

jingwen@jingwen:~/code/tensorflow/bazel-tensorflow/external/androidndk
$ grep -o -E "ndk/.*[^\*]\/" BUILD.bazel | xargs file | sort | uniq

# .. snip ..

ndk/platforms/android-24/arch-arm64/:                                  directory
ndk/platforms/android-24/arch-arm/:                                    directory
ndk/platforms/android-24/arch-mips64/:                                 directory
ndk/platforms/android-24/arch-mips/:                                   directory
ndk/platforms/android-24/arch-x86_64/:                                 directory
ndk/platforms/android-24/arch-x86/:                                    directory
ndk/sources/android/cpufeatures/:                                      directory
ndk/sources/android/support/include/:                                  directory
ndk/sources/cxx-stl/gabi++/include/:                                   directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/backward/:               directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/:                        directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/:                 directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include/:         directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/:                   directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include/:           directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/:               directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/:       directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/:                    directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/include/:            directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/:                      directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/include/:              directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/:                    directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include/:            directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/:                       directory
ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include/:               directory
ndk/sources/cxx-stl/llvm-libc++abi/libcxxabi/include/:                 cannot open `ndk/sources/cxx-stl/llvm-libc++abi/libcxxabi/include/' (No such file or directory)
ndk/sources/cxx-stl/llvm-libc++/libcxx/include/:                       cannot open `ndk/sources/cxx-stl/llvm-libc++/libcxx/include/' (No such file or directory)
ndk/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/:                       directory
ndk/sources/cxx-stl/llvm-libc++/libs/armeabi/:                         directory
ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/:                     directory
ndk/sources/cxx-stl/llvm-libc++/libs/mips64/:                          directory
ndk/sources/cxx-stl/llvm-libc++/libs/mips/:                            directory
ndk/sources/cxx-stl/llvm-libc++/libs/x86_64/:                          directory
ndk/sources/cxx-stl/llvm-libc++/libs/x86/:                             directory
ndk/sources/cxx-stl/stlport/libs/arm64-v8a/:                           directory
ndk/sources/cxx-stl/stlport/libs/armeabi/:                             directory
ndk/sources/cxx-stl/stlport/libs/armeabi-v7a/:                         directory
ndk/sources/cxx-stl/stlport/libs/mips64/:                              directory
ndk/sources/cxx-stl/stlport/libs/mips/:                                directory
ndk/sources/cxx-stl/stlport/libs/x86_64/:                              directory
ndk/sources/cxx-stl/stlport/libs/x86/:                                 directory
ndk/sources/cxx-stl/stlport/stlport/:                                  directory
ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/:   directory
ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/:       directory
ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/:   directory
ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/:       directory
ndk/toolchains/llvm/:                                                  directory
ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/:                        directory
ndk/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64/bin/:  directory
ndk/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64/:      directory
ndk/toolchains/mipsel-linux-android-4.9/prebuilt/linux-x86_64/bin/:    directory
ndk/toolchains/mipsel-linux-android-4.9/prebuilt/linux-x86_64/:        directory
ndk/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/:                     directory
ndk/toolchains/x86-4.9/prebuilt/linux-x86_64/:                         directory
ndk/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/:                  directory
ndk/toolchains/x86_64-4.9/prebuilt/linux-x86_64/:                      directory

@etnu
Copy link

etnu commented Feb 22, 2018

Is there something that can be patched in to fix that then?

@jin
Copy link
Member

jin commented Feb 22, 2018

fix is incoming here: https://bazel-review.googlesource.com/c/bazel/+/40712

The patchdiffs on Gerrit are a little bit wonky, however.

@jin
Copy link
Member

jin commented Feb 23, 2018

Hi all, the fix for this is in master. Please feel free to try it out and let me know if you still face problems - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants