nvlink error : Undefined reference to 'cublasZgemm_v2' in ******.obj'

Hey guys,
here is the program;
global void DoubleMatrixFatherOnGPU(double2 dataOut,double2 dataIn,myMatrixSize dataSize)
int i= blockIdx.x ;
int n=dataSize.weidth/dataSize.height;
cublasHandle_t handle;
double2 alpha,beta;

and then,when I compiled the program,the compile result is as followed;
nvlink error : Undefined reference to ‘cublasZgemm_v2’ in ****.obj’
But when the function cublasZgemm() was launched from the Host,it was OK. So I have no ideas,why did this happened?It would be very appratiated for any advice!Thank you!

The compile command is different when you use/launch a cublas function from device code.

Since you haven’t actually shown the compile command, I can’t say anything else.

Study the cuda sample codes/projects that use cublas and also cublas in device code to see the compile command differences.

Thanks for your reply!
I use the compile command 'mexcuda -dynamic myMexFunction.cu ’ to compile CUDA with mex in Matlab .In myMexFunction.cu,It has involved the following code:
#include “cublas_v2.h”
#pragma comment (lib,“cudart”)
#pragma comment (lib,“cublas”)
#pragma comment (lib,“cublas_device”)
#pragma comment (lib,“cuda”)
#pragma comment (lib,“cudadevrt”)

in Matlab I have set the path ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\lib\x64’ correctly.
when the function ‘cublasZgemm()’ was launched from the Host,there is no problem and the runnig result was correct.But when the function ‘cublasZgemm()’ was launched from device code,the problem mentioned above would appear.
Could you tell me what difference it is when I use/launch a cublas function from device code?
I’m looking forward your reply.Thanks a lot!

Yes, that compile command won’t work.

Take a look at the simpleDevLibCublas sample project, use the makefile to build the code, and see how the compile commands differ from the ordinary cublas projects.

Thanks a lot !
I think I would give up.It is complex to use cuda In Matlab compared with only using the CUDA. Have you ever compile CUDA with mex in Matlab ?