nvmex with debug information

Hello,

I’ve wrote a cuda-program with matlab interface and I want to compile my program with debug information. When I use the command “nvmex -g -f nvmexoptsemul.bat cuda_SobelFilter.cu -IC:\cuda\include -LC:\cuda\lib -lcudart”, I get the following error:

Usage : nvcc [options]

C:\PROGRA~1\MATLAB\R2007A\BIN\NVMEX.PL: Error: Compile of ‘cuda_SobelFilter.cu’ failed.

Without the flag -g it works fine.

How can I compile my files with debug information?

Should I make some changes in the nvmexoptemul.bat?

I use WindowsXP, Matlab 7.4.0 R2007a and Visual Studio 2005 and the following nvmexoptemul.bat

@echo off
rem MSVC80OPTS.BAT
rem
rem Compile and link options used for building MEX-files
rem using the Microsoft Visual C++ compiler version 8.0
rem
rem Revision: 1.1.10.2 Date: 2006/06/23 19:04:53
rem
rem ********************************************************************
rem General parameters
rem ********************************************************************

set MATLAB=%MATLAB%
set VS80COMNTOOLS=%VS80COMNTOOLS%
set VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8
set VCINSTALLDIR=%VSINSTALLDIR%\VC
set PATH=%VCINSTALLDIR%\BIN;%VCINSTALLDIR%\PlatformSDK\bin;%VSINSTALLDIR%\Common7\IDE;%VSINSTALLDIR%\SDK\v2.0\bin;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%VCINSTALLDIR%\VCPackages;%MATLAB_BIN%;%PATH%
set INCLUDE=%VCINSTALLDIR%\ATLMFC\INCLUDE;%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\PlatformSDK\INCLUDE;%VSINSTALLDIR%\SDK\v2.0\include;%INCLUDE%
set LIB=%VCINSTALLDIR%\ATLMFC\LIB;%VCINSTALLDIR%\LIB;%VCINSTALLDIR%\PlatformSDK\lib;%VSINSTALLDIR%\SDK\v2.0\lib;%MATLAB%\extern\lib\win32;%LIB%
set MW_TARGET_ARCH=win32

rem ********************************************************************
rem Compiler parameters
rem ********************************************************************
set COMPILER=nvcc
set COMPFLAGS=-deviceemu -c -D_WCHAR_T_DEFINED -Xcompiler “/c /Zp8 /GR /W3 /EHsc- /Zc:wchar_t- /DMATLAB_MEX_FILE /nologo”
set OPTIMFLAGS=-D_WCHAR_T_DEFINED -Xcompiler “/MD /O2 /Oy- /DNDEBUG”
set DEBUGFLAGS=-D_WCHAR_T_DEFINED -Xcompiler “/MD /Zi /Fd”%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set NAME_OBJECT=-o

rem ********************************************************************
rem Linker parameters
rem ********************************************************************
set LIBLOC=%MATLAB%\extern\lib\win32\microsoft
set LINKER=link
rem set LINKER=nvcc
set LINKFLAGS=/dll /export:%ENTRYPOINT% /MAP /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /implib:%LIB_NAME%.x /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
set LINKOPTIMFLAGS=
set LINKDEBUGFLAGS=/DEBUG /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set LINK_FILE=
set LINK_LIB=
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
set RSP_FILE_INDICATOR=@

rem ********************************************************************
rem Resource compiler parameters
rem ********************************************************************
set RC_COMPILER=rc /fo “%OUTDIR%mexversion.res”
set RC_LINKER=

set POSTLINK_CMDS=del “%OUTDIR%%MEX_NAME%.map”
set POSTLINK_CMDS1=del %LIB_NAME%.x
set POSTLINK_CMDS2=mt -outputresource:"%OUTDIR%%MEX_NAME%%MEX_EXT%";2 -manifest “%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest”
set POSTLINK_CMDS3=del “%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest”

thanks a lot,
volkmar

Yes, make the changes in the nvmexopt.bat file. You can create a new one for debugging.

Hello,

Which changes should i make?

i’ve made some changes in the COMPFLAGS (-g):

set COMPFLAGS=-g -deviceemu -c -D_WCHAR_T_DEFINED -Xcompiler “/c /Zp8 /GR /W3 /EHsc- /Zc:wchar_t- /DMATLAB_MEX_FILE /nologo”

…but nothing happens. The compiler does not generate the *.pdb with the debug information.

I need this information because afterwards I would like to debug my program with Visual Studio 2005 by attach to Matlab process.

thanks,
volkmar

The flags for the host compiler are the one after -Xcompiler.
I don’t know the compiler flag to enable debug in VisualStudio, but whatever it is, should go there.

thanks for your answer.

With the following changes I was able to generate a *.pdb file.


rem Compiler parameters
rem ********************************************************************
set COMPILER=nvcc
set COMPFLAGS=-g -c -D_WCHAR_T_DEFINED -Xcompiler “/Zi /c /Zp8 /GR /W3 /EHsc- /Zc:wchar_t- /DMATLAB_MEX_FILE /nologo”
set OPTIMFLAGS=-D_WCHAR_T_DEFINED -Xcompiler “/MD /Oy-”
set DEBUGFLAGS=-D_WCHAR_T_DEFINED -Xcompiler “/MD /Zi /Fd”%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set NAME_OBJECT=-o

thanks,
volkmar