声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2072|回复: 2

[混合编程] 将C转换成Mex文件

[复制链接]
发表于 2010-6-22 08:50 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我将文件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 [y]/n? y

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

[0] None

Compiler: 1

Please verify your choices:

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

Are these correct?([y]/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: 718  undeclared identifier `SBA_OPTSSZ'
Error sba.c: 718  integer expression must be constant
Error sba.c: 718  undeclared identifier `SBA_INIT_MU'
Error sba.c: 718  initializer must be constant
Error sba.c: 718  undeclared identifier `SBA_STOP_THRESH'
Error sba.c: 718  initializer must be constant
Error sba.c: 718  initializer must be constant
Error sba.c: 718  initializer must be constant
Error sba.c: 718  too many initializers
Error sba.c: 719  undeclared identifier `SBA_INFOSZ'
Error sba.c: 719  integer expression must be constant
Error sba.c: 1051  undeclared identifier `SBA_ERROR'
Warning sba.c: 1051   possible usage of SBA_ERROR before definition
Warning sba.c: 1093  indexing array info[5] out of bounds (1)
Warning sba.c: 1093  indexing array info[6] out of bounds (1)
Warning sba.c: 1093  indexing array info[1] out of bounds (1)
Warning sba.c: 1093  indexing array info[7] out of bounds (1)
Warning sba.c: 1093  indexing array info[8] out of bounds (1)
Warning sba.c: 1093  indexing array info[9] 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文件通过上述方法是可以顺利转换的。

请大家指教!!
回复
分享到:

使用道具 举报

发表于 2010-6-23 08:23 | 显示全部楼层
这方面个人没玩过! 不太清楚, sorry
但记得好像有人讨论过, 建议LZ先搜下
同待高人路过

[ 本帖最后由 ChaChing 于 2010-6-23 08:25 编辑 ]
 楼主| 发表于 2010-6-23 12:46 | 显示全部楼层
谢谢对问题的留意
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-26 02:06 , Processed in 0.051791 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表