Simulink S-Function与C ++代码编译但在生成/设置时出错

时间:2010-11-24 12:02:37

标签: c++ matlab simulink

我有一个C ++例程,我想在Simulink S-Function中打包。这个C ++例程调用其他几个C ++文件中的其他例程。

我可以设法使用legacy_code工具编译所有内容(即生成mexglx文件)。但是,会发出以下警告:

Warning: You are using gcc version "4.4.4-14ubuntu5)".  The earliest gcc version
supported  with mex is "4.1".  The latest version tested for use with mex 
is "4.2". To download a different version of gcc, visit http://gcc.gnu.org 

当我尝试通过发出命令生成S-Function块时出现问题:

legacy_code('slblock_generate', def);

此时,提出了以下提及GLIBCXX版本的错误:

??? Error using ==> iAddSfunctionBlock at 183
Error due to multiple causes.

Error in ==>
/opt/matlab/toolbox/simulink/simulink/+legacycode/@LCT/generateslblock.p>
generateslblock at 55


Error in ==> /opt/matlab/toolbox/simulink/simulink/legacy_code.p>legacy_code at
160


Caused by:
    Error using ==> iAddSfunctionBlock at 183
    Invalid MEX-file 'sfun_vectorRotation_b.mexglx':
    /opt/matlab/bin/glnx86/../../sys/os/glnx86/libstdc++.so.6: version
    `GLIBCXX_3.4.11' not found (required by sfun_vectorRotation_b.mexglx).
    Error using ==> iAddSfunctionBlock at 183
    Error while obtaining sizes from MEX S-function 'sfun_vectorRotation_b' in
    'untitled1/sfun_vectorRotation_b'. MATLAB error message:
    Invalid MEX-file 'sfun_vectorRotation_b.mexglx':
    /opt/matlab/bin/glnx86/../../sys/os/glnx86/libstdc++.so.6: version
    `GLIBCXX_3.4.11' not found (required by sfun_vectorRotation_b.mexglx).

老实说,此时我有点失落。我不知道降级g ++编译器是否足够,或者我是否还要做其他事情。你有解决这个问题的方法吗?

我在Ubuntu 10.10操作系统中使用Matlab 2009b,而g ++版本是:

g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5

提前多多感谢

米克尔

1 个答案:

答案 0 :(得分:2)

最后我可以自己解决问题。只需下载并安装(通过./configuremakemake install)支持的gcc版本(4.1和4.2之间的任何人都可以)。在我的情况下,我尝试了gcc-4.2,它工作正常。

非常感谢!

米克尔