flathub / org.freedesktop.Sdk.Extension.openjdk11

9 stars 13 forks source link

Could NOT find JNI #21

Closed tobias47n9e closed 3 years ago

tobias47n9e commented 3 years ago

Not sure if this is a Bug or me not knowing enough about Cmake and Java. When I add the extension

sdk-extensions:
  - org.freedesktop.Sdk.Extension.openjdk1

I run into this error while building a CMAKE module:

INFO RT-extension not found. glTF import/export will be built without Open3DGC-compression.
-- Enabled formats: 3DS COLLADA LWO OBJ BLEND
-- Disabled formats: AMF AC ASE ASSBIN ASSXML B3D BVH DXF CSM HMP IRRMESH IRR LWS MD2 MD3 MD5 MDC MDL NFF NDO OFF OGRE OPENGEX PLY MS3D COB IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD
-- Found AWK: /usr/bin/awk  
-- AWK version: GNU Awk 5.1.0, API: 3.0
-- Found AI Wrapper: CUtils (sources only wrapper)
-- Found AI Interface: C-AIInterface 0.1
-- Found Java: /usr/lib/sdk/openjdk11/bin/java (found version "11.0.11") found components: Development 
CMake Error at /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
  JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
Call Stack (most recent call first):
  /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.20/Modules/FindJNI.cmake:382 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  AI/Interfaces/Java/CMakeLists.txt:255 (find_package)

Is JNI part of this extension or is there a way of adding it? Sorry for using the issue tracker for support question.

tobias47n9e commented 3 years ago

Using this in the manifest I could get the number of errors down:

build-options:
  env:
    PATH: /app/bin:/usr/bin:/usr/lib/sdk/openjdk11/bin
    JAVA_HOME: /app/jre
    CMAKE_JAVA_INCLUDE_PATH: /usr/lib/sdk/openjdk11/
    JAVA_AWT_LIBRARY: /usr/lib/sdk/openjdk11/jvm/openjdk-11/lib/libawt.so
    JAVA_JVM_LIBRARY: /app/jre/lib/server/libjvm.so
    JAVA_INCLUDE_PATH: /usr/lib/sdk/openjdk11/jvm/openjdk-11/include
    JAVA_INCLUDE_PATH2: /usr/lib/sdk/openjdk11/jvm/openjdk-11/include/linux
    JAVA_AWT_INCLUDE_PATH: /app/jre/lib

Now it is only complaining about 3 env variables:

Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
tobias47n9e commented 3 years ago

Perhaps all is solved by setting:

build-options:
  env:
    JAVA_HOME: /usr/lib/sdk/openjdk11/jvm/openjdk-11/
mbooth101 commented 3 years ago

Yes JNI is shipped as part of this extension.

The extension also ships a "enable.sh" script to set up your environment if needed.

Sourcing it will set up your JAVA_HOME and PATH variables appropriately. E.g. you should be able to do:

source /usr/lib/sdk/openjdk11/enable.sh && my_build_command

Hope that helps