Curand Host API question Error during linking (VS 2008)

Hi Everybody!

This Curand program has errors when I comile it in Visual Studio 2008!

1>Linking...

1>particio.cu.obj : error LNK2019: unresolved external symbol _curandDestroyGenerator@4 referenced in function _main

1>particio.cu.obj : error LNK2019: unresolved external symbol _curandGenerateUniform@12 referenced in function _main

1>particio.cu.obj : error LNK2019: unresolved external symbol _curandSetPseudoRandomGeneratorSeed@12 referenced in function _main

1>particio.cu.obj : error LNK2019: unresolved external symbol _curandCreateGenerator@8 referenced in function _main

1>bin/win32/Debug/particio.exe : fatal error LNK1120: 4 unresolved externals

1>Build log was saved at "file://c:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\src\Curand\Debug\BuildLog.htm"

1>Curand - 5 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

And a simple curand program:

#include <iostream>

#include <stdlib.h>

#include <curand.h>

int main()

{

  size_t n = 100;

  size_t i;

  curandGenerator_t gen;

  float *devData, *hostData;

  /* Allocate n floats on host */

  hostData = (float *)calloc(n, sizeof(float));

  /* Allocate n floats on device */

  cudaMalloc((void **)&devData, n * sizeof(float));

  /* Create pseudo-random number generator */

  curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT);

  /* Set seed */

  curandSetPseudoRandomGeneratorSeed(gen, 1234ULL);

  /* Generate n floats on device */

  curandGenerateUniform(gen, devData, n);

  /* Copy device memory to host */

  cudaMemcpy(hostData, devData, n * sizeof(float),

                       cudaMemcpyDeviceToHost);

  /* Set seed */

  curandSetPseudoRandomGeneratorSeed(gen, 1234ULL);

  /* Generate n floats on device */

  curandGenerateUniform(gen, devData, n);

  /* Copy device memory to host */

  cudaMemcpy(hostData, devData, n * sizeof(float),

                       cudaMemcpyDeviceToHost);

  /* Show result */

  for(i = 0; i < n; i++) {

    printf("%1.4f ", hostData[i]);

  }

  printf("\n");

  /* Cleanup */

  curandDestroyGenerator(gen);

  cudaFree(devData);

  free(hostData);

  return EXIT_SUCCESS;

}

What I did wrong? What do you think? Thank You!

Nobody knows what did I wrong?

I think you need to add “curand.lib” in your additional dependencies.

project → property → configuration properties → linker → input → additional properties → add “curand.lib”

also, you may want to check if you have add the path into additional library directories.

project → property → configuration properties → linker → general → additional library directories → add the directories “curand.lib” resides.

hope it will help.

Problem solved. It works with this solution. Thank You!