title: How to compile multiple files in cuda?
body: <p>I did it the way I do with gcc</p>
  
  <pre><code> nvcc a.cu ut.cu 
  </code></pre>
  
  <p>but the compiler shows </p>
  
  <pre><code>ptxas fatal   : Unresolved extern function '_Z1fi'
  </code></pre>
  
  <p>The problem only occurs when the function is __device__ function.</p>
  
  <p>[File ut.h]</p>
  
  <pre><code>__device__ int f(int);
  </code></pre>
  
  <p>[File ut.c]</p>
  
  <pre><code>#include "ut.h"
  
  __device__ int f(int a){ 
      return a*a;
  }
  </code></pre>
  
  <p>[File a.cu]</p>
  
  <pre><code>#include "ut.h"
  
  __global__ void mk(){
      f(5);
  }
  
  
  int main(){
      mk&lt;&lt;&lt;1,1&gt;&gt;&gt;();
  }
  </code></pre>