Mex compile a C++ code
Mostrar comentarios más antiguos
>> 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.
1 comentario
Walter Roberson
el 28 de Mayo de 2011
Is yprime.c definitely in your working directory? For example, if you try
!dir yprime.c
does it show the file?
Respuesta aceptada
Más respuestas (1)
Jan
el 30 de Mayo de 2011
Please insert new information by editing your question - sending emails is less efficient and I dislike it, especially if it contains 5MB of data.
From your mail:
mex('-O', fullfile(matlabroot, 'extern', 'examples', 'compiler', 'yprime.c'))
Could Not Find C:\Program Files\MATLAB\R2007b\extern\examples\mex\yprime.exp
Something is confused now: Where does "extern\examples\compiler\" come from? yprime.c is in "extern\examples\mex\" - as in the error message. But then the error message and the shown code do not match?!
I suggest to start from the beginning: Delete the exp and lib files created in different folders, copy yprime.c to a new directory, add it to the Matlab PATH, CD to this directory and try to mex the C-file again. I recommend to use the MSVC compiler, because LCC cannot compile C++ code.
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!