CURAND Library - Compiling Error - Undefined reference to functions
I suppose my understanding of linker flags is less than substantial as I don't understand how to use them. Do I need to put the code in my makefile for the program I am running it with? Can someone please explain by writing out the syntax and where I would need to put it? Also, can I simply put the curand.lib file from the CUDA library in the program folder I want to use it with and reference it from there?
Here is the code I am attempting to use to generate a random number for a raytracer program. Any help is greatly appreciated.
float drandGPU()
{
std::size_t n = 1;
std::size_t i;
curandGenerator_t gen;
float *devData, *hostData;
hostData = (float*) calloc(n, sizeof(float));
cudaMalloc((void**) &devData, n*sizeof(float));
curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_MTGP32);
curandSetPseudoRandomGeneratorSeed(gen, 1234ULL);
curandGenerateUniform(gen,devData,n);
cudaMemcpy(hostData, devData, n*sizeof(float), cudaMemcpyDeviceToHost);
float f = hostData[0];
return f;
}
EDIT: I am adding the makefile here:
all: exe
exe: pipe
g++ -o rayTracer -D__PIKOC_HOST__ -I/usr/local/cuda/include -I../../api/include -I../.. -I. main.cpp -L/usr/local/cuda/lib -lcuda -lGL -lglut
pipe:
../../bin/pikoc --numRuns=10 --timer main.cpp
clean:
rm -f rayTracer __pikoDefines.h __pikoCompiledPipe.h __pikoCompiledPipe.ptx