title: Problem with loading compiled c code in R x64 using dyn.load
body: <p>I recently went from a 32bit laptop to a 64bit desktop (both win7). I just found out that I get an error now when loading dll's using <code>dyn.load</code>. I guess this is a simple mistake and I am overlooking something. </p>
  
  <p>For example, I write this simple c function (foo.c):</p>
  
  <pre><code>void foo( int *x) {*x = *x + 1;}
  </code></pre>
  
  <p>Then compile it in command prompt:</p>
  
  <pre><code>R CMD SHLIB foo.c
  </code></pre>
  
  <p>Then in 32bit R I can use it in  R:</p>
  
  <pre><code>&gt; dyn.load("foo.dll")
  &gt; .C("foo",as.integer(1))
  [[1]]
  [1] 2
  </code></pre>
  
  <p>but in 64bit R I get:</p>
  
  <pre><code>&gt; dyn.load("foo.dll")
  Error in inDL(x, as.logical(local), as.logical(now), ...) : 
    unable to load shared object 'C:/Users/Sacha/Documents/R/foo.dll':
    LoadLibrary failure:  %1 is not a valid Win32 application.
  nd.
  </code></pre>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>For reference, R CMD can be forced in an architecture by using <code>--arch 64x</code> :</p>
  
  <pre><code>R --arch x64 CMD SHLIB foo.c
  </code></pre>
  
  <p>Quite clear actually, I knew I was making a rooky mistake:)</p>