Reputation: 3
For work, I am converting the Image Denoising program that comes with the CUDA SDK into a MATLAB program. As far as I know, I have made all the necessary changes required by MATLAB, but when I try to call mex on it, MATLAB returns a bunch of linkage errors that I have no idea how to fix. If anyone has any suggestions on what I might be doing wrong, I would greatly appreciate it.
The command I am giving MATLAB is:
mex imageDenoisingGL.cpp -I..\..\common\inc -IC:\CUDA\include -L..\..\common\lib -lglut32
And the output from MATLAB is a bunch of these:
imageDenoisingGL.obj : error LNK2019: unresolved external symbol __imp__cutCheckCmdLineFlag@12 referenced in function "void __cdecl __cutilExit(int,char * *)" (?__cutilExit@@YAXHPAPAD@Z)
I am running:
Windows XP x32
Visual Studio 2005
MATLAB 2007a
Upvotes: 0
Views: 1360
Reputation: 21475
High Performance Mark is suggesting, in his comment, to compile mexfiles using CUDA directly under Visual Studio. At the page
Compiling CUDA mex files with Visual Studio
it is described how the compile mexfiles using CUDA under Visual Studio. There is also a downloadable Visual Studio sample project.
The procedure has been tested for CUDA 5.0, Visual Studio 2010 and Matlab 2010a/2012b, but perhaps it could be of interest also to people using other versions of the above products.
Upvotes: 0
Reputation: 25140
You need to link the CUDA libraries to your MEX file. It looks like you're also using some of the "cutil.h"
stuff from the CUDA SDK (such as cutCheckCmdLineFlag
), so you'll need to link against not only the cudart library, but also cutil. I.e. you probably need to add something like
-Lc:\CUDA\lib -lcudart -lcuda -L<path-to-cutil.lib> -lcutil
to your MEX command-line.
Upvotes: 1
Reputation: 101456
If you are converting from CUDA to MATLAB, then why are you still calling the CUDA functions?
unresolved external symbol __imp__cutCheckCmdLineFlag@12
Upvotes: 1