title: JNI: Problems compiling 64-bit native libraries
body: <p>I compiled a native DLL file on Windows (64-bit) with GCC flags -c and -o Name.dll.</p>
  
  <p>When I did System.load("fullpahhere"), I get this error:</p>
  
  <pre><code>java.lang.UnsatisfiedLinkError: RenderControl.dll: %1 is not a valid Win32 application
  </code></pre>
  
  <p>If I recompile adding a blank main() method to the C source and removing the -c flag, it then fails with an UnsatisfiedLinkError that says it can't load a 32 bit DLL on a 64 bit machine.</p>
  
  <p>Why is Java calling a DLL with no main method invalid?  Doesn't that ruin the whole point of DLL files and the JNI?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I fixed the main() issue.  This GCC invocation setup works:</p>
  
  <pre><code>gcc -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at -I "C:\Program Files\Java\jdk1.6.0_32\include" -I "C:\Program Files\Java\jdk1.6.0_32\include\win32" -shared *.c -o lib.dll
  </code></pre>
  
  <p>I still need to figure out the JVM Architecture problem, however.</p>
  
  <p>Where can I find a MinGW installation that is capable of compilnig 64 bit code?  It seems my standard MinGW install only does 32 bit.</p>
  
  <p>If I can get my hands on that, how do I decide which library to load in Java?  Is there a System property that shows the <strong>JVM arch</strong> (<strong>NOT</strong> the OS arch)?</p>