编译mex c matlab,在Matlab中编译mex文件时找不到标准C库

更新:我在mexopts.sh中安装了XCode并更改了SDKROOT以反映

here所述的实际路径,但是当我包含mex.h时仍然会出现此错误:

In file included from /Applications/MATLAB_R2012b.app/extern/include/matrix.h:294,

from /Applications/MATLAB_R2012b.app/extern/include/mex.h:58,

from test.c:2:

/Applications/MATLAB_R2012b.app/extern/include/tmwtypes.h:61:21: error: float.h: No such file or directory

mex: compile of ' "test.c"' failed.

我正在尝试通过mex编译一个简单的C文件以供在Matlab中使用,但它似乎从未找到我知道安装的默认库.例如,尝试编译以下内容:

#include

int main() {

return 0;

}

给我错误:

test.c:1:20: error: string.h: No such file or directory

mex: compile of ' "test.c"' failed.

即使它使用gcc编译好.更糟糕的是,当我尝试将mex.h包括在内时:

#include "mex.h"

int main() {

return 0;

}

我收到以下错误:

In file included from /Applications/MATLAB_R2012b.app/extern/include/mex.h:58,

from test.c:2:

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:293:20: error: stddef.h: No such file or directory

In file included from /Applications/MATLAB_R2012b.app/extern/include/matrix.h:294,

from /Applications/MATLAB_R2012b.app/extern/include/mex.h:58,

from test.c:2:

/Applications/MATLAB_R2012b.app/extern/include/tmwtypes.h:43:20: error: limits.h: No such file or directory

/Applications/MATLAB_R2012b.app/extern/include/tmwtypes.h:46:21: error: stdbool.h: No such file or directory

/Applications/MATLAB_R2012b.app/extern/include/tmwtypes.h:61:21: error: float.h: No such file or directory

/Applications/MATLAB_R2012b.app/extern/include/tmwtypes.h:777:2: error: #error "This code must be compiled using a 2's complement representation for signed integer values"

In file included from /Applications/MATLAB_R2012b.app/extern/include/matrix.h:294,

from /Applications/MATLAB_R2012b.app/extern/include/mex.h:58,

from test.c:2:

/Applications/MATLAB_R2012b.app/extern/include/tmwtypes.h:823: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CHAR16_T'

In file included from /Applications/MATLAB_R2012b.app/extern/include/mex.h:58,

from test.c:2:

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:319: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mxChar'

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:375: error: expected ')' before 'n'

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:383: error: expected ')' before 'n'

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:397: error: expected declaration specifiers or '...' before 'size_t'

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:590: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mxGetNumberOfElements'

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:632: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:688: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mxGetM'

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:700: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mxGetN'

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:750: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mxGetElementSize'

In file included from /Applications/MATLAB_R2012b.app/extern/include/mex.h:58,

from test.c:2:

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:851:20: error: stdlib.h: No such file or directory

/Applications/MATLAB_R2012b.app/extern/include/matrix.h:1072: error: expected ')' before 'm'

In file included from test.c:2:

/Applications/MATLAB_R2012b.app/extern/include/mex.h:91: error: expected specifier-qualifier-list before 'size_t'

In file included from test.c:2:

/Applications/MATLAB_R2012b.app/extern/include/mex.h:161:19: error: stdio.h: No such file or directory

mex: compile of ' "test.c"' failed.

我假设mex没有找到这些库的正确位置,或者安装在某种程度上已损坏,但我不知道如何修复它.

Mac OSX Mountain Lion XCode 4.5.2,Matlab R2012b,gcc 4.2.1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值