title: VISUAL STUDIO 2013 : error LNK2019: unresolved external symbol - cuRAND - Random Number Generator
body: <p>I have researched for hours, </p>
  
  <ol>
  <li><a href="https://msdn.microsoft.com/en-us/library/799kze2z.aspx" rel="nofollow noreferrer">MSDN Microsoft - Linker Tools Error LNK2019</a></li>
  <li><a href="https://stackoverflow.com/questions/19886397/how-to-solve-the-error-lnk2019-unresolved-external-symbol-function">How to solve the error LNK2019: unresolved external symbol - function?</a></li>
  <li><a href="https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix">What is an undefined reference/unresolved external symbol error and how do I fix it?</a></li>
  <li><a href="https://stackoverflow.com/questions/21243235/error-lnk2019-unresolved-external-symbol-wwinmain16-referenced-in-function">Error LNK2019: unresolved external symbol _wWinMain@16 referenced in function ___tmainCRTStartup</a></li>
  <li><p><a href="https://stackoverflow.com/questions/8528863/how-to-get-rid-of-this-error-msvcrtd-libcrtexe-obj-error-lnk2019-unresolv">How to get rid of this error: &quot;MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup&quot;</a></p>
  
  <p>but have not found a way to resolve the following error,</p></li>
  </ol>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Error 1 error LNK2019: unresolved external symbol _curandCreateGenerator@8 referenced in function _GPU_RNG F:\New\Eks\Visual Studio 2013\PEOPLE PROJECTS\RNGTests\CURANDRNGLib\CURANDRNG.cu.obj CURANDRNGLib
  Error 2 error LNK2019: unresolved external symbol _curandCreateGeneratorHost@8 referenced in function _CPU_RNG F:\New\Eks\Visual Studio 2013\PEOPLE PROJECTS\RNGTests\CURANDRNGLib\CURANDRNG.cu.obj CURANDRNGLib
  Error 3 error LNK2019: unresolved external symbol _curandDestroyGenerator@4 referenced in function _GPU_RNG F:\New\Eks\Visual Studio 2013\PEOPLE PROJECTS\RNGTests\CURANDRNGLib\CURANDRNG.cu.obj CURANDRNGLib
  Error 4 error LNK2019: unresolved external symbol _curandSetPseudoRandomGeneratorSeed@12 referenced in function _GPU_RNG F:\New\Eks\Visual Studio 2013\PEOPLE PROJECTS\RNGTests\CURANDRNGLib\CURANDRNG.cu.obj CURANDRNGLib
  Error 5 error LNK2019: unresolved external symbol _curandGenerateUniform@12 referenced in function _GPU_RNG F:\New\Eks\Visual Studio 2013\PEOPLE PROJECTS\RNGTests\CURANDRNGLib\CURANDRNG.cu.obj CURANDRNGLib</code></pre>
  </div>
  </div>
  </p>
  
  <p>CURANDRNGLib.cu</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>#include &lt;cuda.h&gt;
  #include &lt;cuda_runtime.h&gt;
  #include &lt;curand.h&gt;
  #include &lt;curand_kernel.h&gt;
  
  using namespace std;
  extern "C" __declspec(dllexport) void __cdecl GPU_RNG(float* , unsigned int , unsigned int);
  extern "C" __declspec(dllexport) void __cdecl CPU_RNG(float* , unsigned int , unsigned int);
  
  
  extern void GPU_RNG(float * h_randomData, unsigned int dataCount, unsigned int mainSeed)
  {
   float * d_randomData = 0;
  
   //allocate device memory
   size_t randomDataSize = dataCount * sizeof(float);
   cudaMalloc((void**)&amp;d_randomData, randomDataSize);
  
   curandGenerator_t m_prng;
   //Create a new generator
   curandCreateGenerator(&amp;m_prng, CURAND_RNG_PSEUDO_DEFAULT);
   //Set the generator options
   curandSetPseudoRandomGeneratorSeed(m_prng, (unsigned long) mainSeed);
   //Generate random numbers
   curandGenerateUniform(m_prng, d_randomData, dataCount);
   //Copy memory back to the device
   cudaMemcpy(h_randomData, d_randomData, randomDataSize, cudaMemcpyDeviceToHost);
   //Clean
   curandDestroyGenerator(m_prng);
   //free device memory
   cudaFree(d_randomData);
  }
  
  extern void CPU_RNG(float * h_randomData, unsigned int dataCount, unsigned int mainSeed)
  {
   curandGenerator_t m_prng;
   //Create a new generator
   curandCreateGeneratorHost(&amp;m_prng,CURAND_RNG_PSEUDO_DEFAULT);
   //Set the generator options
   curandSetPseudoRandomGeneratorSeed(m_prng, (unsigned long) mainSeed);
   //Generate random numbers
   curandGenerateUniform(m_prng, h_randomData, dataCount);
   //Clean
   curandDestroyGenerator(m_prng);
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Should I add a #include? (I'm not good at english very much)</p>