how to make jni.h be found?

后端 未结 11 1355
轻奢々
轻奢々 2020-11-30 03:10

In Ubuntu 12.04, I have jdk7 from sun/oracle installed. When locate jni.h, it prints multiple locations

/usr/lib/jvm/java-6-openjdk-amd64/inclu         


        
11条回答
  •  臣服心动
    2020-11-30 03:15

    Above answers give you a hardcoded path solution. This is bad on so many levels (java version change, OS change, etc).

    Cleaner solution is to add:

    JAVA_HOME = $(shell dirname $$(readlink -f $$(which java))|sed 's^jre/bin^^')
    

    near the top of your makefile, then add:

    -I$(JAVA_HOME)/include
    

    To your include flags.

    I am posting this because I ran into the same problem and spent too much time googling for wrong answers (I am building an app on multiple platforms so the build environment needs to be transportable).

提交回复
热议问题