title: How can I compile CUDA code then link it to a C++ project?
body: <p>I am looking for help getting started with a project involving CUDA. My goal is to have a project that I can compile in the native g++ compiler but uses CUDA code. I understand that I have to compile my CUDA code in nvcc compiler, but from my understanding I can somehow compile the CUDA code into a cubin file or a ptx file.</p>
  
  <p>Here are my questions:</p>
  
  <ol>
  <li>How do I use nvcc to compile into a cubin file or a ptx file? Don't I need a -c or something?</li>
  <li>Which file type do I want to use?</li>
  <li>What are the g++ commands to correctly compile and link the project together?</li>
  </ol>
  
  <p>Assume the following:</p>
  
  <ol>
  <li>I have a file called "main.cpp" that has a main function in it and includes cuda.h.</li>
  <li>I have another file called "cudaFunc.cu" that has CUDA code in it. Let's say, for instance, that I want to add two integer arrays that exist in main.cpp.</li>
  </ol>