# Matlab compilation error

**URL:** <https://forums.developer.nvidia.com/t/matlab-compilation-error/1656>\
**Category:** CUDA Programming and Performance\
**Created:** [October 18, 2007, 2:44pm UTC](https://forums.developer.nvidia.com/t/matlab-compilation-error/1656 "2007-10-18T14:44:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sicb0161](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sicb0161](https://forums.developer.nvidia.com/u/sicb0161)\
**Post date:** [October 18, 2007, 2:44pm UTC](https://forums.developer.nvidia.com/t/matlab-compilation-error/1656/1 "2007-10-18T14:44:15Z")

</div>

In Matlab it try to compile the example in matlab using the instruction in the readme.txt but I get an error.

Dont understand where the mistake is.

> [@](#):
>
> nvmex -f nvmexopts.bat Szeta.cu -IF:\cuda\include -LF:\cuda\lib -lcufft -lcudart
> 
> ‘cl’ is not recognized as an internal or external command,
> 
> operable program or batch file.
> 
> F:\PROGRA~1\MATLAB\R2007A\BIN\NVMEX.PL: Error: Compile of ‘Szeta.cu’ failed.
> 
> ??? Error using ==\> nvmex at 206
> 
> Unable to complete successfully.

---

<div class="post-metadata">

**Author:** ![mfatica](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mfatica](https://forums.developer.nvidia.com/u/mfatica)\
**Post date:** [October 18, 2007, 4:44pm UTC](https://forums.developer.nvidia.com/t/matlab-compilation-error/1656/2 "2007-10-18T16:44:53Z")

</div>

The script is using Visual studio.

Run " mex -setup" to select Visual Studio as your default compiler for mex.  
There are instructions on the web on how to use Visual Studio Express if you don’t have the full version.

---

<div class="post-metadata">

**Author:** ![sicb0161](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sicb0161](https://forums.developer.nvidia.com/u/sicb0161)\
**Post date:** [October 19, 2007, 7:52am UTC](https://forums.developer.nvidia.com/t/matlab-compilation-error/1656/3 "2007-10-19T07:52:37Z")

</div>

> [@](#):
>
> The script is using Visual studio.
> 
> Run " mex -setup" to select&nbsp; Visual Studio as your default compiler for mex.
> 
> There are instructions on the web on how to use Visual Studio Express if you don’t have the full version.
> 
> [snapback]266567[/snapback]

Did the setup, still does not work with the same error. \<img src=‘[http://hqnveipbwb20/public/style\_emoticons/](http://hqnveipbwb20/public/style_emoticons/)\<#EMO\_DIR#\>/crying.gif’ class=‘bbc\_emoticon’ alt=‘:’(’ /\>

---

<div class="post-metadata">

**Author:** ![mfatica](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mfatica](https://forums.developer.nvidia.com/u/mfatica)\
**Post date:** [October 19, 2007, 12:42pm UTC](https://forums.developer.nvidia.com/t/matlab-compilation-error/1656/4 "2007-10-19T12:42:48Z")

</div>

Can you post the output of:

1. a verbose build of a simple C mex file: mex -v file.c

2. a verbose output of the cuda mex file: nvmex -v … Seta.cu

---

<div class="post-metadata">

**Author:** ![sicb0161](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sicb0161](https://forums.developer.nvidia.com/u/sicb0161)\
**Post date:** [October 19, 2007, 1:09pm UTC](https://forums.developer.nvidia.com/t/matlab-compilation-error/1656/5 "2007-10-19T13:09:13Z")

</div>

> [@](#):
>
> Can you post the output of:
> 
> 1. a verbose build of a simple C mex file:&nbsp; mex -v file.c
> 
> 2. a verbose output of the cuda mex file: nvmex -v …&nbsp; Seta.cu
> 
> [snapback]266917[/snapback]

1. 

dont have problems with mex compilations , but okay:

mex -v ifft2\_cuda.c -IF:\CUDA\include -LF:\CUDA\lib -lcudart -lcufft

This is mex, Copyright 1984-2006 The MathWorks, Inc.

→ Default options filename found in F:\Documents and Settings\Cem Bassoy\Application Data\MathWorks\MATLAB\R2007a

* * *

→ Options file = F:\Documents and Settings\Cem Bassoy\Application Data\MathWorks\MATLAB\R2007a\mexopts.bat

```
  MATLAB = F:\PROGRA~1\MATLAB\R2007a 

```

→ COMPILER = cl

→ Compiler flags:

```
     COMPFLAGS = /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo 

     OPTIMFLAGS = /MD /O2 /Oy- /DNDEBUG 

     DEBUGFLAGS = /MD /Zi /Fd"ifft2_cuda.mexw32.pdb" 

     arguments = -IF:\CUDA\include 

     Name switch = /Fo 

```

→ Pre-linking commands =

→ LINKER = link

→ Link directives:

```
     LINKFLAGS = /dll /export:mexFunction /MAP /LIBPATH:"F:\PROGRA~1\MATLAB\R2007a\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /implib:F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex_7020BEAB-D22D-410A-9CA4-1678BE7F4843\templib.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 

     LINKDEBUGFLAGS = /DEBUG /PDB:"ifft2_cuda.mexw32.pdb" 

     LINKFLAGSPOST =  

     Name directive = /out:"ifft2_cuda.mexw32" 

     File link directive =  

     Lib. link directive =  

     Rsp file indicator = @ 

```

→ Resource Compiler = rc /fo “mexversion.res”

→ Resource Linker =

* * *

→ “cl -IF:\CUDA\include /c /Zp8 /GR /W3 /EHs /D\_CRT\_SECURE\_NO\_DEPRECATE /D\_SCL\_SECURE\_NO\_DEPRECATE /D\_SECURE\_SCL=0 /DMATLAB\_MEX\_FILE /nologo /FoF:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex\_7020BEAB-D22D-410A-9CA4-1678BE7F4843\ifft2\_cuda.obj -IF:\PROGRA~1\MATLAB\R2007a\extern\include -IF:\PROGRA~1\MATLAB\R2007a\simulink\include /MD /O2 /Oy- /DNDEBUG -DMX\_COMPAT\_32 ifft2\_cuda.c”

ifft2\_cuda.c

ifft2\_cuda.c(43) : warning C4244: ‘=’ : conversion from ‘double’ to ‘float’, possible loss of data

ifft2\_cuda.c(44) : warning C4244: ‘=’ : conversion from ‘double’ to ‘float’, possible loss of data

ifft2\_cuda.c(62) : warning C4244: ‘=’ : conversion from ‘double’ to ‘float’, possible loss of data

ifft2\_cuda.c(63) : warning C4244: ‘=’ : conversion from ‘double’ to ‘float’, possible loss of data

ifft2\_cuda.c(90) : warning C4244: ‘=’ : conversion from ‘double’ to ‘float’, possible loss of data

ifft2\_cuda.c(106) : warning C4244: ‘=’ : conversion from ‘double’ to ‘float’, possible loss of data

ifft2\_cuda.c(150) : warning C4244: ‘=’ : conversion from ‘double’ to ‘int’, possible loss of data

ifft2\_cuda.c(151) : warning C4244: ‘=’ : conversion from ‘double’ to ‘int’, possible loss of data

ifft2\_cuda.c(120) : warning C4101: ‘output\_single’ : unreferenced local variable

ifft2\_cuda.c(118) : warning C4101: ‘i’ : unreferenced local variable

```
Contents of F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex_7020BEAB-D22D-410A-9CA4-1678BE7F4843\mex_tmp.rsp: 

```

F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex\_7020BEAB-D22D-410A-9CA4-1678BE7F4843\ifft2\_cuda.obj

→ "link /out:“ifft2\_cuda.mexw32” /dll /export:mexFunction /MAP /LIBPATH:“F:\PROGRA~1\MATLAB\R2007a\extern\lib\win32\microsoft” libmx.lib libmex.lib libmat.lib /implib:F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex\_7020BEAB-D22D-410A-9CA4-1678BE7F4843\templib.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 @F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex\_7020BEAB-D22D-410A-9CA4-1678BE7F4843\mex\_tmp.rsp F:\CUDA\lib\cudart.lib F:\CUDA\lib\cufft.lib "

Microsoft ® Incremental Linker Version 8.00.50727.42

Copyright © Microsoft Corporation. All rights reserved.

F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex\_7020BEAB-D22D-410A-9CA4-1678BE7F4843\ifft2\_cuda.obj

Creating library F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex\_7020BEAB-D22D-410A-9CA4-1678BE7F4843\templib.x and object F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex\_7020BEAB-D22D-410A-9CA4-1678BE7F4843\templib.exp

→ “del “ifft2\_cuda.map””

→ “del F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex\_7020BEAB-D22D-410A-9CA4-1678BE7F4843\templib.x”

→ “mt -outputresource:“ifft2\_cuda.mexw32”;2 -manifest “ifft2\_cuda.mexw32.manifest””

Microsoft ® Manifest Tool version 5.2.3790.2014

Copyright © Microsoft Corporation 2005.

All rights reserved.

→ “del “ifft2\_cuda.mexw32.manifest””

1. 

nvmex -v -f nvmexopts.bat Szeta.cu -IF:\cuda\include -LF:\cuda\lib -lcufft -lcudart

This is mex, Copyright 1984-2005 The MathWorks, Inc.

→ Options file specified on command line

* * *

→ Options file = nvmexopts.bat

```
  MATLAB = F:\PROGRA~1\MATLAB\R2007a 

```

→ COMPILER = nvcc

→ Compiler flags:

```
     COMPFLAGS = -c -Xcompiler "/c /Zp8 /GR /W3 /EHsc- /Zc:wchar_t- /DMATLAB_MEX_FILE /nologo" 

     OPTIMFLAGS = -Xcompiler "/MD /O2 /Oy- /DNDEBUG" 

     DEBUGFLAGS = -Xcompiler "/MD /Zi /Fd"Szeta.mexw32.pdb" 

     arguments = -IF:\cuda\include 

     Name switch = -o 

```

→ Pre-linking commands =

→ LINKER = link

→ Link directives:

```
     LINKFLAGS = /dll /export:mexFunction /MAP /LIBPATH:"F:\PROGRA~1\MATLAB\R2007a\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /implib:F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex_921B5419-D03C-44B8-C296-3FB29C1B5B68\templib.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 

     LINKDEBUGFLAGS = /DEBUG /PDB:"Szeta.mexw32.pdb" 

     LINKFLAGSPOST =  

     Name directive = /out:"Szeta.mexw32" 

     File link directive =  

     Lib. link directive =  

     Rsp file indicator = @ 

```

→ Resource Compiler = rc /fo “mexversion.res”

→ Resource Linker =

* * *

→ “nvcc -IF:\cuda\include -c -Xcompiler “/c /Zp8 /GR /W3 /EHsc- /Zc:wchar\_t- /DMATLAB\_MEX\_FILE /nologo” -o F:\DOCUME~1\CEMBAS~1\LOCALS~1\Temp\mex\_921B5419-D03C-44B8-C296-3FB29C1B5B68\Szeta.obj -IF:\PROGRA~1\MATLAB\R2007a\extern\include -IF:\PROGRA~1\MATLAB\R2007a\simulink\include -Xcompiler “/MD /O2 /Oy- /DNDEBUG” -DMX\_COMPAT\_32 Szeta.cu”

‘cl’ is not recognized as an internal or external command,

operable program or batch file.

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

---

<div class="post-metadata">

**Author:** ![devermyst](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@devermyst](https://forums.developer.nvidia.com/u/devermyst)\
**Post date:** [August 5, 2008, 4:12pm UTC](https://forums.developer.nvidia.com/t/matlab-compilation-error/1656/6 "2008-08-05T16:12:43Z")

</div>

Hello All

I’m new here… I just begin with Cuda and as it seems i’m not only to have some problem for using/installing it I NEED HELP :

So I have VS05, I’ve installed the SDK the toolkit and i want to use cuda with MATLAB…?

I can compile Mex File, but when i try to compile cuda file (the example) i have :

nvcc fatal : Could not open input file C:\DOCUME~1\rootlocal\Local Settings\Temp/tmpxft\_00000430\_00000000-1

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

Somebody know what can i do

Thks a lot

---

<div class="post-metadata">

**Author:** ![AnnaLinn](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@AnnaLinn](https://forums.developer.nvidia.com/u/AnnaLinn)\
**Post date:** [April 20, 2009, 8:12pm UTC](https://forums.developer.nvidia.com/t/matlab-compilation-error/1656/7 "2009-04-20T20:12:36Z")

</div>

I am getting the same error. I have set my compiler to Microsoft Visual Studio 2008 (done using the mex -setup command), and am using Matlab 2008a. When I try to compile, I get the following error. Please let me know what I can do to fix this.

Thanks!

nvmex -f nvmexopts.bat Szeta.cu -IC:\cuda\include -LC:\cuda\lib -lcufft -lcudart  
nvcc fatal : nvcc cannot find a supported cl version. Only MSVC 8.0 and MSVC 9.0 are supported

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

??? Error using ==\> nvmex at 206  
Unable to complete successfully.

> >
