bazel for jni: jni.h file not found

不羁岁月 提交于 2019-12-24 10:35:02

问题


I'm trying to use bazel to build my JNI library (written in C). No luck after about 4 hours: "jni.h file not found". How can I put the JDK include directories on the search path? Tried using absolute paths but bazel rejects those. Trying to use a new_local_repository for the JDK but cannot see how to make it work.

This is bazel 0.5.3 on MacOS 10.12.6, Java 1.8


回答1:


Can you depend on @local_jdk//:jni_header or some other magic labels from https://github.com/bazelbuild/bazel/blob/117da7a947b4f497dffd6859b9769d7c8765443d/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE? However if you're using custom --java_base it won't work.

E.g. this works for me:

cc_library(
    name = "foo",
    srcs = [ 
        "@local_jdk//:jni_header",
        "@local_jdk//:jni_md_header-linux",
        "foo.cc"
    ],
    includes = [ "external/local_jdk/include/linux" ],
)


来源:https://stackoverflow.com/questions/46160790/bazel-for-jni-jni-h-file-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!