MATLAB: Mex compile a C++ code

mexmex -setupmex compiler

>> mex -setup Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler: [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2007b\sys\lcc
[0] None
Compiler: 1
Please verify your choices:
Compiler: Lcc-win32 C 2.4.1 Location: C:\PROGRA~1\MATLAB\R2007b\sys\lcc
Are these correct?([y]/n): y
Trying to update options file: C:\Users\hp\AppData\Roaming\MathWorks\MATLAB\R2007b\mexopts.bat From template: C:\PROGRA~1\MATLAB\R2007b\bin\win32\mexopts\lccopts.bat
Done . . .
>> mex yprime.c
C:\PROGRA~1\MATLAB\R2007B\BIN\MEX.PL: Error: 'yprime.c' not found.
??? Error using ==> mex at 208 Unable to complete successfully.
I could not able to compile a simple C code in my matlab. Even after installing Microsoft Visual C++ 6.0 compiler. its showing the above mentioned error. I am new to this topic can anybody help me out regarding it.

Best Answer

"yprime.c" can be found in the examples folder. Either change into this directory:
cd(fullfile(matlabroot, 'extern', 'examples', 'mex'));
mex -O yprime.c
Or specify the file with the full path:
mex('-O', fullfile(matlabroot, 'extern', 'examples', 'mex', 'yprime.c')
If you do not have write permissions for this folder, copy the C-file to a folder you can access.
This is explained in the section "Building MEX-Files" in the documentation.
Related Question