wwb624 发表于 2010-6-22 08:50

将C转换成Mex文件

我将文件sba.c和sba.h分别放置到工作目录:D:\MATLAB71\work\SBA下面,运行下面的指令,出现下面的信息:

>> mex -setup
Please choose your compiler for building external interface (MEX) files:

Would you like mex to locate installed compilers /n? y

Select a compiler:
Lcc C version 2.4.1 in D:\MATLAB71\sys\lcc
Microsoft Visual C/C++ version 6.0 in D:\Microsoft Visual Studio

None

Compiler: 1

Please verify your choices:

Compiler: Lcc C 2.4.1
Location: D:\MATLAB71\sys\lcc

Are these correct?(/n): y

Try to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R14SP3\mexopts.bat
From template:            D:\MATLAB71\BIN\win32\mexopts\lccopts.bat

Done . . .

***************************************************************************
Warning: The file extension of 32-bit Windows MEX-files was changed
         from ".dll" to ".mexw32" in MATLAB 7.1 (R14SP3). The generated
         MEX-file will not be found by MATLAB versions prior to 7.1.
         Use the -output option with the ".dll" file extension to
         generate a MEX-file that can be called in previous versions.
         For more information see:
         MATLAB 7.1 Release Notes, New File Extension for MEX-Files on Windows
***************************************************************************

>> cd d:/MATLAB71/work/SBA
>> mex sba.c
lcc preprocessor error: sba.c:29 Could not find include file <sba.h>
Error sba.c: 718undeclared identifier `SBA_OPTSSZ'
Error sba.c: 718integer expression must be constant
Error sba.c: 718undeclared identifier `SBA_INIT_MU'
Error sba.c: 718initializer must be constant
Error sba.c: 718undeclared identifier `SBA_STOP_THRESH'
Error sba.c: 718initializer must be constant
Error sba.c: 718initializer must be constant
Error sba.c: 718initializer must be constant
Error sba.c: 718too many initializers
Error sba.c: 719undeclared identifier `SBA_INFOSZ'
Error sba.c: 719integer expression must be constant
Error sba.c: 1051undeclared identifier `SBA_ERROR'
Warning sba.c: 1051   possible usage of SBA_ERROR before definition
Warning sba.c: 1093indexing array info out of bounds (1)
Warning sba.c: 1093indexing array info out of bounds (1)
Warning sba.c: 1093indexing array info out of bounds (1)
Warning sba.c: 1093indexing array info out of bounds (1)
Warning sba.c: 1093indexing array info out of bounds (1)
Warning sba.c: 1093indexing array info out of bounds (1)
Warning sba.c: 719   possible usage of SBA_INFOSZ before definition
Warning sba.c: 718   possible usage of SBA_STOP_THRESH before definition
Warning sba.c: 718   possible usage of SBA_INIT_MU before definition
Warning sba.c: 718   possible usage of SBA_OPTSSZ before definition
13 errors, 11 warnings

D:\MATLAB71\BIN\MEX.PL: Error: Compile of 'sba.c' failed.

??? Error using ==> mex
Unable to complete successfully
>>

我明明将sba.h放到了工作目录下,为何还是提示error: sba.c:29 Could not find include file <sba.h> ??我该怎么处理这种C文件里面包含其他.h文件的文件,才能将其成功转换出.mexw32文件来??

我尝试了,如果C文件不包含其他的.h文件通过上述方法是可以顺利转换的。

请大家指教!!

ChaChing 发表于 2010-6-23 08:23

这方面个人没玩过! 不太清楚, sorry
但记得好像有人讨论过, 建议LZ先搜下
同待高人路过

[ 本帖最后由 ChaChing 于 2010-6-23 08:25 编辑 ]

wwb624 发表于 2010-6-23 12:46

谢谢对问题的留意
页: [1]
查看完整版本: 将C转换成Mex文件