Unresolved external symbol problem with CUBLAS solved (WinXP)

I was getting a LNK2019 unresolved external symbol error when trying to link my mixed Fortran/C application using CUBLAS. The error showed up at every call to a routine in the CUBLAS library from the fortran.c wrapper, for example

fortran.obj : error LNK2019: unresolved external symbol _cublasInit@0 referenced in function _CUBLAS_INIT

I saw some similar posts about problems, but no useful solutions. I am running on Windows XP using MSVS 2005 and Intel Visual Fortran 11.0. I tried it both from the command line and through the VS IDE. I was sure I had all the right compile and link options selected and libraries available. I saw a couple of posts about issues with x64 versus Win32. My machine is running XP64, but the application I was building was targetted for Win32. (I had some existing Fortran object code that I had to integrate with and it was already built for Win32.) For normal Windows applications it is possible to switch between Win32 and x64 targets just by setting the desired Configuration in the IDE. It finally occured to me that there might be an issue with the version of cublas.lib on my machine. I installed a copy of the 32bit CUDA SDK on another machine and copied the /lib and /bin directories back to my machine. I put then in a Win32 directory under C:/CUDA. In VS I set the project properties for the Win32 configuration to point to these libraries instead of the default ones. This cleared up my link errors and the application built correctly.

I am posting this because it took me a while to get to this as the solution. It was not obvious that the problem was a 32/64 mismatch. I had not worked with Fortran in a long time, and never on a PC, so I was thinking the problem was Fortran related. The error message makes it look like cublas.lib is not there or not found. It really is there and found, it just doesn’t satisfy the calling program because of the 32/64 difference. It seems pretty obvious now, but isn’t it always that way!