Trouble using CUBLAS (new to CUDA) unresolved external symbols

Hi all,

        I ve been trying out CUDA for just around a month now and I am still finding my way around. I recently decided to try using the cublas libraries. But I am having some problems in getting my code to compile. I get errors saying "Unresolved external symbol _cublasInit@0 referenced in function _main". I get one error message of this sort for every cublas function that I have tried to use in my code.

        The error seems to say that "cublasInit is an unrecognized function. But then, I am not getting any linking error for the 'cublas.h' header and I checked inside 'cublas.h' file to see if there is any problem in it, and all functions that I use are defined in that. In desperation, I even tried copying over all the required header files into the include directory of Microsoft visual C++ and then compile using "cl".. But i still get the same error.. 

        I am at a loss to understand what the problem is. I would greatly appreciate any help I can get..



You need to link the CUBLAS library (-lcublas in Linux, look at the simpleBLAS example in the SDK for the correct syntax in Windows), the include file has nothing to do with the linker.

Hi Mfatica,

Thanks a lot for pointing that out.

The syntax for windows is “nvcc <program_name> cublas.lib” in the command line. Or you can put in #pragma comment(lib,“cublas.lib”) as a part of your code. Just posting that in case anyone else has the same question later.