0
votes

I'm a newbie in MATLAB. I am trying to build my modell with an example for S-Function from the matlab help. This is the sfun_counter_cpp.cpp. The source code is available in "matlabroot/simulink/src/sfun_counter_cpp.cpp" or on http://www-rohan.sdsu.edu/doc/matlab/toolbox/simulink/sfg/sfun_c++2.html.

First I build C++ S-function with the "mex" command as described here: http://www.mathworks.de/de/help/simulink/sfg/building-c-s-functions.html. The build is successful and the sfun_counter_cpp.mexw32 is created. After that I create an S-Function block that provides access to sfun_counter_cpp from my block diagram, click "Incremental build" and get an error message "OPUS MAKE: Don't know how to make 'sfun_counter_cpp.cppm50'. Stop."

*** Found User-Code File TestModell_usr.c from 05-Jul-2013 15:38:59
*** Found User Makefile TestModell_usr.mk from 05-Jul-2013 15:38:59
*** Optional User Variable Description File TestModell_usr.trc not available
.
### Processing Template Makefile: C:\dSPACE\matlab\rti1005\m\rti1005.tmf
### TestModell.mk which is generated from C:\dSPACE\matlab\rti1005\m\rti1005.tmf is up to date
### Building TestModell: dsmake -f TestModell.mk  GENERATE_REPORT=0 EXTMODE_STATIC_ALLOC=0 TMW_EXTMODE_TESTING=0 EXTMODE_STATIC_ALLOC_SIZE=1000000 EXTMODE_TRANSPORT=0

BUILDING APPLICATION "TestModell" (Multiple Timer Task Mode) 

WORK  DIRECTORY "c:\MyTest" 
BUILD DIRECTORY "c:\MyTest\TestModell_rti1005" 
TARGET COMPILER "C:\PPCTools37"  

COMPILING  "TestModell.c"  
COMPILING  "TestModell_data.c"  
COMPILING  "TestModell_trc_ptr.c"  
COMPILING  "rtGetInf.c"  
COMPILING  "rtGetNaN.c"  
COMPILING  "C:\PROGRA~2\MATLAB~1\rtw\c\src\rt_matrx.c"  
COMPILING  "rt_nonfinite.c"  
COMPILING  "C:\dSPACE\MATLAB\RTI1005\C\rt_printf.c"  
COMPILING  "C:\dSPACE\MATLAB\RTI1005\C\rti_sim_engine.c"  
OPUS MAKE: Don't know how to make 'sfun_counter_cpp.cppm50'. Stop. 
----------------------------------------------------------------------
*** Errors occurred during make process.
*** Inspect MATLAB Command Window for details.
*** Aborting RTI build procedure for model TestModell.
----------------------------------------------------------------------
*** Stopped RTI build procedure for model: TestModell.
----------------------------------------------------------------------
1
Why are you using a dSPACE target? Can you try with the GRT target first to see if the problem comes from the target or S-function itself? - am304
How can I try it with the GRT? - Hans Holzbart
In the Configuration Parameters window, go to the Code Generation node (might be called slightly differently depending on which release you are using), and select the GRT target. You really need to know and understand the basic of code generation with Simulink before trying to generate code from a model with an S-function. Check the documentation for Simulink Coder (or Real-Time Workshop in older releases). If you just want to simulate the model, rather than generate code, you don't need the "incremental build", just press play to run the model. - am304
Hi am304, thanks for the tip with "incremental build" and the play button. The error was caused because I didn't add my cpp file to my TestModell_usr.mk file. I added two lines USER_BUILD_CPP_APPL = ON and USER_SRCS = sfun_counter_cpp.cpp. Now I have an other error: < lnkppc > (E) #A0307-D Symbol: sfun_counter_cpp in file: sfun_counter_cpp.cppm50 already defined in file: sfun_counter_cpp.cppm50 - Hans Holzbart
Sorry don't know, but I will ask again: are you really trying to generate code from your model or do you just want to "run" (simulate) your model? For simulation, you don't need the incremental build. For generating code, do you really need a dSPACE target? - am304

1 Answers

0
votes

The problem is solved. I set

USER_BUILD_CPP_APPL = ON

and

USER_SRCS =

USER_SRCS = sfun_counter_cpp.cpp produces an error

< lnkppc > (E) #A0307-D Symbol: sfun_counter_cpp in file: sfun_counter_cpp.cppm50 already defined in file: sfun_counter_cpp.cppm50