title: CUDA 6.0 Linking error: undefined reference to `__cudaUnregisterFatBinary'
body: <p>I am trying to compile a simple CUDA program in Eclipse. </p>
  
  <pre><code>g++ -L/opt/cuda/lib64 -o "cuda_esn" ./cu_cuda_test.o ./main.o -lcuda -lstdc++
  </code></pre>
  
  <p>As you can see I am linking <code>-lcuda</code> and set the library path <code>-L/opt/cuda/lib64</code>. But unfortunately I have no idea why this is not compiling.</p>
  
  <p>Complete output:</p>
  
  <pre><code>18:36:35 **** Incremental Build of configuration Default for project cuda_esn ****
  make all 
  Building file: ../cuda_test.cu
  Invoking: CUDA NVCC Compiler
  nvcc -c  -o "cu_cuda_test.o" "../cuda_test.cu" &amp;&amp; \
  echo -n 'cu_cuda_test.d' ./ &gt; 'cu_cuda_test.d' &amp;&amp; \
  nvcc -M   "../cuda_test.cu" &gt;&gt; 'cu_cuda_test.d'
  nvcc warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release.
  nvcc warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release.
  Finished building: ../cuda_test.cu
  
  Building target: cuda_esn
  Invoking: C++ Linker
  g++ -L/opt/cuda/lib64 -o "cuda_esn"  ./cu_cuda_test.o ./main.o   -lcuda -lstdc++
  ./cu_cuda_test.o: In function `__cudaUnregisterBinaryUtil()':
  makefile:32: recipe for target 'cuda_esn' failed
  tmpxft_00001041_00000000-3_cuda_test.cudafe1.cpp:(.text+0x49): undefined reference to `__cudaUnregisterFatBinary'
  ./cu_cuda_test.o: In function `__nv_init_managed_rt_with_module(void**)':
  tmpxft_00001041_00000000-3_cuda_test.cudafe1.cpp:(.text+0x63): undefined reference to `__cudaInitModule'
  ./cu_cuda_test.o: In function `__sti____cudaRegisterAll_44_tmpxft_00001041_00000000_6_cuda_test_cpp1_ii_aeee46d9()':
  tmpxft_00001041_00000000-3_cuda_test.cudafe1.cpp:(.text+0x9c): undefined reference to `__cudaRegisterFatBinary'
  collect2: error: ld returned 1 exit status
  make: *** [cuda_esn] Error 1
  </code></pre>
  
  <hr>
  
  <p>This would be the source code (not really exciting yet):</p>
  
  <p>cuda_test.h</p>
  
  <pre><code>#ifndef CUDARR
  #define CUDARR
  
  #ifdef __cplusplus
    extern "C"
  #endif
  
  void foo_wrapper();
  
  #endif
  </code></pre>
  
  <p>cuda_test.cu</p>
  
  <pre><code>#include "cuda_test.h"
  #include "cuda.h"
  #include "cuda_runtime.h"
  
  extern "C" void foo_wrapper()
  {
  }
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "cuda_test.h"
  
  int main() {
  
    std::cout &lt;&lt; "hello world" &lt;&lt; std::endl;
  
    foo_wrapper();
  
    return 0;
  }
  </code></pre>
  
  <p>Can anybody help me?</p>