error: undefined reference to 'cudaMemcpy'

Display card of CUDA GPU is: Geforce 8600GT
On ubuntu 10.04, CUDA 6.0 is correctly installed.
nvcc -v, I get the folowing information:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2013 NVIDIA Corporation
Built on Thu_Mar_13_11:42:14_PDT_2014
Cuda compilation tools, release 6.0, V6.0.1

My code can be correctly built, but I get the following error during linking:
error: undefined reference to ‘cudaMemcpy’
error: undefined reference to ‘cudaGetErrorString’

Is there anyone knows the reason of my issue?

Probably you haven’t given enough information. It would help to know the exact commands you are using to compile and link your application. Are you linking with nvcc or are you linking with gcc/g++ ?

I am trying to run the code on Ubuntu 12.04. My GPU is Geforce 8600GT. The openCV version I am using is 2.4.0. Cmake version is 2.8.7. The compiler is g++ 4.6.3.

Cuda 6.0 is correctly installed on my system. I can make the samepler code in /usr/local/cuda-6.0/samples/ folder by make command.

I don’t care the sppeed of the compiled code. I only want to verify whether the function of my code is correct, so I use an old CUDA hardware that is only available.

One more questions:
Previously, I don’t know how to compile OpenCV with CUDA, so I make OpenCV without CUDA installed on my system. Should I install CUDA at first and then make OpenCV? otherwise, CUDA related code in OpenCV will not be compiled during the making of OpenCV. Is my understanding correct?

You still haven’t shown the actual compile/link commands that are producing the error. Probably the actual error is due to linking with g++, but not specifying the proper cudart (CUDA runtime) library during the link phase. However settting up a proper OpenCV/CUDA environment requires a number of steps, that I personally can’t cover here. However there are many how-to and tutorial pages on the web. You might try following one of them.

In CMakeCache.txt file, I get the following lines:
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++

//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING=

//Flags used by the compiler during debug builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=-g

//Flags used by the compiler during release minsize builds.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG

//Flags used by the compiler during release builds (/MD /Ob1 /Oi
// /Ot /Oy /Gs will produce slightly less optimized but smaller
// files).
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG

//Flags used by the compiler during Release with Debug Info builds.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g

//C compiler.
CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc

I think the compiler is gcc.

Yesterday, I tried to re-install OpenCV after CUDA 6.0 was correctly installed on my computer. In this situation, OpenCV can be correctly made and made install.
after that, I re-made my code, I got the following errors:
error: undefined reference to ‘cv::gpu::CudaMem::~CudaMem()’
error: undefined reference to ‘cv::gpu::CudaMem::canMapHostMemory()’

^^
Somewhere in your OpenCV code, there is a reference to those functions, and you are probably missing an include statement, so the compiler does not know where to find them.

Syntax of said function: [url]http://fossies.org/dox/opencv-2.4.8/classcv_1_1gpu_1_1CudaMem.html[/url]