开发者

Simulink S-Function with C++ code compiles but gives an error at generation/set-up

开发者 https://www.devze.com 2023-01-27 06:02 出处:网络
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 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).
开发者_C百科

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号