CLion JNI

已完成

Hello,
how can I get CLion to find jni.h?

I'm working on Ubuntu 21.10, CLion 2022.1.3, created a new project -> C Library (C99 static).

main.c

#include <stdio.h>
#include <jni.h> // FILE NOT FOUND

int main() {
    printf("Hello, World!\n");
    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.22)
project(libask_cmake C)

find_package(JNI)

set(CMAKE_C_STANDARD 99)

add_executable(libask_cmake main.c)

if (JNI_FOUND)
    message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
    message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
endif()
评论操作 固定链接

Solution that worked for me:

echo $JAVA_HOME must be available and:

CMakeLists.txt

cmake_minimum_required(VERSION 3.22)
project(libask_cmake C)

find_package(JNI REQUIRED)
include_directories(${JNI_INCLUDE_DIRS})

set(CMAKE_C_STANDARD 99)

add_executable(libask_cmake main.c)
0

请先登录再写评论。