mlc-ai / mlc-llm

Universal LLM Deployment Engine with ML Compilation
https://llm.mlc.ai/
Apache License 2.0
19.26k stars 1.58k forks source link

/opt/AI/llm_obj/mlc-llm/3rdparty/tvm/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc:232:31: error: cannot initialize a parameter of type 'void **' with an rvalue of type 'JNIEnv **' (aka 'JNIEnv_ **') 232 | _jvm->AttachCurrentThread(&env, nullptr); | ^~~~ /usr/local/java/jdk-17.0.11/include/jni.h:1938:37: note: passing argument to parameter 'penv' here 1938 | jint AttachCurrentThread(void **penv, void *args) { | ^ /opt/AI/llm_obj/mlc-llm/3rdparty/tvm/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc:309:31: error: cannot initialize a parameter of type 'void **' with an rvalue of type 'JNIEnv **' (aka 'JNIEnv_ **') #2259

Closed lbl1120 closed 6 months ago

lbl1120 commented 6 months ago

csyw@ubuntu:/opt/AI/llm_obj/mlc-llm/android/library$ ./prepare_libs.sh

-- TVM_HOME: /opt/AI/llm_obj/mlc-llm/android/library/../../3rdparty/tvm -- Found Java: /usr/local/java/jdk-17.0.11/bin/java (found version "17.0.11") -- Found JNI: /usr/local/java/jdk-17.0.11/include/linux
-- JNI_INCLUDE_DIRS=/root/Android/Sdk/ndk/27.0.11718014/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include;/usr/local/java/jdk-17.0.11/include/linux;/usr/local/java/jdk-17.0.11/include -- JNI_LIBRARIES=/usr/local/java/jdk-17.0.11/include/linux;/usr/local/java/jdk-17.0.11/include/linux -- Configuring done -- Generating done -- Build files have been written to: /opt/AI/llm_obj/mlc-llm/android/library/build

tqchen commented 6 months ago

likely it depends on the JNI environment you are using, previosly android jni was directly triggred as https://github.com/apache/tvm/blob/main/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc#L232 which pass in the address and normal java should not have TVM4J_ANDROID defined, whichi will trigger the other path that relates to here. I am not sure what was specifically happening in your case

lbl1120 commented 6 months ago

I modified this file /mlc-llm/android/library/CMakeLists.txt Added this content 2024-05-04_094517

The following is the configuration of my environment variables

2024-05-04_094237

tqchen commented 6 months ago

This is due to your JAVA_HOME setting, we highly recommend pointing to Android studio's jdk, see also https://github.com/mlc-ai/mlc-llm/pull/2327

tqchen commented 6 months ago

checkout the latest instructions here https://llm.mlc.ai/docs/deploy/android.html