tags:

views:

132

answers:

2

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

+1  A: 

If you are converting from CUDA to MATLAB, then why are you still calling the CUDA functions?

unresolved external symbol _imp_cutCheckCmdLineFlag@12

John Dibling
I'm not quite sure what you mean here. The file I'm trying to convert is a .cpp file that calls external CUDA functions to perform operations on an image. I want to retain that functionality in the MEX file so I'm calling those functions. I'm pretty inexperienced with both, though, so if this is a giant mistake, let me know.
Harold Wellington Graves
@Harold Wellington Graves: CUDA is a runtime system. If you're not running CUDA code, then how can you call the CUDA functions? This would be like trying to write C++ code in a VB project.
John Dibling
I think I see what you're saying. And knowing that gives me a few ideas on how to resolve the problems I've been having. Thanks for the help! I'm going to leave this open a bit longer just to see if anyone else has comments.
Harold Wellington Graves
@Harold Wellington Graves: Good luck!
John Dibling
A: 

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.

Edric