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

发布于 2024-10-04 08:15:56 字数 1718 浏览 2 评论 0原文

我有一个 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

提前非常感谢

Miquel

I have a C++ routine that I would like to pack in a Simulink S-Function. This C++ routines calls other routines that are in several other C++ files.

I could manage to have everything compiled (i.e. the mexglx file is generated) using the legacy_code tool. However, the following warning is issued:

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 

The problem arises when I try to generate the S-Function block by issuing the command:

legacy_code('slblock_generate', def);

At this point, the following error mentioning the GLIBCXX version is raised:

??? 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).

Honestly I am a bit lost at this point. I do not know if downgrading the g++ compilator would be enough or if I have to do some other things. Do you have a possible solution for this issue?

I am using Matlab 2009b in an Ubuntu 10.10 OS, and the g++ version is:

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

Thanks a lot in advance

Miquel

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弃爱 2024-10-11 08:15:56

终于我可以自己解决这个问题了。只需下载并安装(通过 ./configuremakemake install)受支持的 gcc 版本(4.1 到 4.2 之间的任何版本都可以) 。就我而言,我尝试了 gcc-4.2 并且工作正常。

无论如何,谢谢!

米盖尔

Finally I could solve the problem myself. Just download and install (via ./configure, make and make install) a supported version of gcc (anyone between 4.1 and 4.2 will do). In my case I tried gcc-4.2 and it works fine.

Thanks anyway!

Miquel

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文