Mex compile a C++ code
显示 更早的评论
>> 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 个评论
Walter Roberson
2011-5-28
Is yprime.c definitely in your working directory? For example, if you try
!dir yprime.c
does it show the file?
采纳的回答
更多回答(1 个)
Jan
2011-5-30
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!