Patrick
Patrick

Reputation: 1019

Compiling C file in Matlab with Visual Studio

I have a C-File that I wanna compile in Matlab with MS Visual Studio 10. For that I use the following command:

mex -v test.c

The output that I get after compilation is the following:

test.c 
    Contents of C:\Temp\mex_kpuu4t\mex_tmp.rsp: 
    C:\Temp\mex_kpuu4t\test.obj 


--> link /out:"test.mexw64" /dll /export:mexFunction /MAP /LIBPATH:"C:\Program Files\MATLAB\R2011a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /implib:"C:\Temp\mex_kpuu4t\templib.x" /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  @C:\Temp\mex_kpuu4t\mex_tmp.rsp   

Microsoft (R) Incremental Linker Version 10.00.30319.01 
Copyright (C) Microsoft Corporation.  All rights reserved. 

C:\Temp\mex_kpuu4t\test.obj  
LINK : fatal error LNK1104: cannot open file 'test.mexw64' 

C:\PROGRA~1\MATLAB\R2011A\BIN\MEX.PL: Error: Link of 'test.mexw64' failed. 

Anyone an idea what could go wrong here? The interesting thing is, that the test.obj file seems not to be written to the temp folder, could that be the issue here?

Many thanks!

Upvotes: 0

Views: 1859

Answers (1)

Itamar Katz
Itamar Katz

Reputation: 9645

Maybe you called "test" from a previously compiled mex? If yes, it might still be loaded to Matlab's memory, and cannot be overwritten. Try:

clear mex

and then compile again.

Upvotes: 1

Related Questions