title: Compiling 64 bit DLL for JNI
body: <p>I want to include a C library in my Java project via JNI. I wrote the necessary JNI wrapper code and I have compiled and tested it in a Linux environment using gcc and make. Now I need to compile this to make a 64 bit Windows DLL, and I cannot get it to compile.</p>
  
  <p>I downloaded Visual C++ Express 2010 and I have been using cl.exe on the command line. In the absence of knowing any better way to do it, I have just called cl.exe with all of the files I want to compile as arguments. I get a variety of errors:</p>
  
  <pre><code>Command line warning D9024: unrecognized source file type 'svm_jni.h'...
  </code></pre>
  
  <p>and</p>
  
  <pre><code>svm_jni.c(63) : error C2275: 'jobject' : illegal use of this type as an expression...
  </code></pre>
  
  <p>The first problem I have discovered is do to the fact that cl.exe does not accept .h files (I guess its only meant for C++ instead of C?). Is there a workaround for this? I could change all of the .h files to .c files and change the include statements, but I would prefer not to do this.</p>
  
  <p>I have tried compiling using make and gcc on MinGW, but it always says that it cannot compile to a 64 bit target.</p>
  
  <p>I have tried doing things through VC++ using the makefile project type, but I could not figure out how that works.</p>
  
  <p>Any suggestions?</p>
  
  <p>EDIT: I removed the .h files from the command line arguments and that solves part of the problem. I have been using</p>
  
  <pre><code>-I "C:\Program Files\Java\jdk1.6.0_21\include" -I "C:\Program Files\Java\jdk1.6.0_21\include\win32"
  </code></pre>
  
  <p>to get jni.h and jni_md.h. I still get</p>
  
  <pre><code>svm_jni.c(63) : error C2275: 'jobject' : illegal use of this type as an expression
      C:\Program Files\Java\jdk1.6.0_21\include\jni.h(83) : see declaration of 'jobject'
  </code></pre>
  
  <p>and a bunch of syntax and weird errors after that. I am assuming all the errors are the result of a common problem, but I don't know whats going wrong.</p>
  
  <p>Is there a 64 bit version of jni_md.h? The one I'm using now is in \include\win32</p>