error: base operand of ‘->’ has non-pointer type ‘JNIEnv’

后端 未结 2 1041
面向向阳花
面向向阳花 2020-12-29 03:53
#include 
#include 

 JNIEnv* create_vm() {
    JavaVM* jvm;
    JNIEnv* env;
    JavaVMInitArgs args;
    JavaVMOption options[1];

             


        
相关标签:
2条回答
  • 2020-12-29 04:45

    I am putting the work around found on other SO posts.. I used straight forwardly this - " gcc -g -I /usr/lib/jvm/java-6-sun-1.6.0.26/include -I /usr/lib/jvm/java-6-sun-1.6.0.26/include/linux -L /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/server -ljvm CallJVM.c and a.out was created. Then I need to link it with libjvm.so present in server folder as mentioned in post.

    A very beautiful explanation has been put up here

    0 讨论(0)
  • 2020-12-29 04:50

    I noticed the different ways of implementing in C and C++ but I think I am writing it correctly.

    You are using the C variant, but are compiling with g++, which invokes the C++ compiler (even if your source file has a .c extension).

    Either change the C variants like

    (*env)->FindClass(env, ...)
    

    to the C++ variants, like

    env->FindClass(...)
    

    or switch your compiler to gcc to compile the source as C code.

    0 讨论(0)
提交回复
热议问题