title: Makefile for JNI invocation not working - undefined reference to JNI_CreateJavaVM
body: <p>I have a makeifile with a task as follows. When I compile, I get a linker error, but I'm not sure why since I"m linking / including to the java libs. I verified that $JAVA_HOME exists and the libjvm.so exists in <code>/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server</code></p>
  
  <p>make error:</p>
  
  <pre><code>(.text+0x5a): undefined reference to `JNI_CreateJavaVM'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>makefile:</p>
  
  <pre><code>my_program:
      gcc -L${JAVA_HOME}/jre/lib/amd64/server/ \
      -I${JAVA_HOME}/include/ \
      -I${JAVA_HOME}/include/linux/ \
      -ljvm \
      my_program.c
  run: my_program
     ./a.out
  </code></pre>
  
  <p>c fiel:</p>
  
  <pre><code>#include &lt;jni.h&gt;
  
  int main ( int argc, char **argv ) {
       printf("hello\n");
       return 0;
  }
  
  
  JNIEnv *create_vm(JavaVM **jvm){
      JNIEnv *env = NULL;
      JavaVMInitArgs vm_args;
      JavaVMOption options;
  //  options.optionString = "-Djava.class.path=" JAVA_PROG_PATH;
  //  vm_args.version = JNI_VERSION_1_7;
      vm_args.nOptions = 1;
      vm_args.options = &amp;options;
      vm_args.ignoreUnrecognized = 0;
      int ret = JNI_CreateJavaVM(jvm, (void **)&amp;env, &amp;vm_args);
      char *failed = "nothing";
      if(ret &lt; 0){
          goto create_vm_error;
  
      }
      return env;
  
      lookup_error:
          dlog(0, "Error looking up class or method %s.\n", failed);
          (**jvm)-&gt;DestroyJavaVM(*jvm);
      create_vm_error:
          *jvm = NULL;
          return NULL;
  }
  </code></pre>