Compiling with CUDA nvcc

I am now trying to use CUDA to modify a source code and I am now learning to build an exectable with both nvcc and gcc,
but I failed,I am building the matrixMul example, did you compiled successfully manually?

the source files are matrixMul_gold.cpp matrixMul.h

and my way is:
nvcc -c
nvcc -c
gcc -c

these three steps are OK
but the last link step failed:
g++ -fPIC -o matrixMul matrixMul.o matrixMul_kernel.o matrixMul_gold.o


Try adding the cuda libraries to the link stage. The SDK sample makefiles contain everything that is required.

Thanks for your reply!