Problem using C API in an application

3 views (last 30 days)
Jose Americo
Jose Americo on 31 May 2013
I am following the tutorial in the section "Use the C API to Access Model Signals and State"( Help-> Product Help->Simulink Coder->User's Guide->Deployment->Program Building, Interaction and Debugging->Data Exchange->Data Interchange Using the C API->Use the C API in an Application).
In the step 14, I click on the 'Build' button and two windows open: the Code Generation Report and a error window that displays the message 'Error(s) encountered while building model "rtwdemo_capi"'.
The ML's main window shows the following:
### Checking for structural changes in rtwdemo_capi_bot because the model reference rebuild option is set to 'If any changes detected'. Structural changes will cause the model reference SIM target to be rebuilt.
### Checking for structural changes in model reference SIM target for model: rtwdemo_capi_bot
### The code for the model reference SIM target for model rtwdemo_capi_bot is up to date because no functional changes exist in the referenced model.
### Checking for structural changes in rtwdemo_capi_bot because the model reference rebuild option is set to 'If any changes detected'. Structural changes will cause the model reference RTW target to be rebuilt.
### Checking for structural changes in model reference RTW target for model: rtwdemo_capi_bot
### The code for the model reference RTW target for model rtwdemo_capi_bot is up to date because no functional changes exist in the referenced model.
### Starting build procedure for model: rtwdemo_capi
C:/PROGRA~1/MATLAB/R2012a\sys\lcc\bin\lcc -c -Fortwdemo_capi.obj -DUSE_RTMODEL -DMODEL=rtwdemo_capi -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0 -DHAVESTDIO -I. -I.. -IC:/PROGRA~1/MATLAB/R2012a\simulink\include -IC:/PROGRA~1/MATLAB/R2012a\extern\include -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\libsrc -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\common -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\tcpip -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\serial -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\custom -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB/rtwdemo_capi_grt_rtw -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB -IC:/PROGRA~1/MATLAB/R2012a/toolbox/rtw/rtwdemos -IC:/PROGRA~1/MATLAB/R2012a\sys\lcc\include -Ireferenced_model_includes -I../slprj/grt/_sharedutils -noregistrylookup rtwdemo_capi.c
C:/PROGRA~1/MATLAB/R2012a\sys\lcc\bin\lcc -c -Fortwdemo_capi_capi.obj -DUSE_RTMODEL -DMODEL=rtwdemo_capi -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0 -DHAVESTDIO -I. -I.. -IC:/PROGRA~1/MATLAB/R2012a\simulink\include -IC:/PROGRA~1/MATLAB/R2012a\extern\include -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\libsrc -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\common -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\tcpip -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\serial -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\custom -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB/rtwdemo_capi_grt_rtw -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB -IC:/PROGRA~1/MATLAB/R2012a/toolbox/rtw/rtwdemos -IC:/PROGRA~1/MATLAB/R2012a\sys\lcc\include -Ireferenced_model_includes -I../slprj/grt/_sharedutils -noregistrylookup rtwdemo_capi_capi.c
C:/PROGRA~1/MATLAB/R2012a\sys\lcc\bin\lcc -c -Fortwdemo_capi_data.obj -DUSE_RTMODEL -DMODEL=rtwdemo_capi -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0 -DHAVESTDIO -I. -I.. -IC:/PROGRA~1/MATLAB/R2012a\simulink\include -IC:/PROGRA~1/MATLAB/R2012a\extern\include -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\libsrc -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\common -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\tcpip -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\serial -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\custom -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB/rtwdemo_capi_grt_rtw -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB -IC:/PROGRA~1/MATLAB/R2012a/toolbox/rtw/rtwdemos -IC:/PROGRA~1/MATLAB/R2012a\sys\lcc\include -Ireferenced_model_includes -I../slprj/grt/_sharedutils -noregistrylookup rtwdemo_capi_data.c
C:/PROGRA~1/MATLAB/R2012a\sys\lcc\bin\lcc -c -Fogrt_main.obj -DUSE_RTMODEL -DMODEL=rtwdemo_capi -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0 -DHAVESTDIO -I. -I.. -IC:/PROGRA~1/MATLAB/R2012a\simulink\include -IC:/PROGRA~1/MATLAB/R2012a\extern\include -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\libsrc -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\common -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\tcpip -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\serial -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\custom -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB/rtwdemo_capi_grt_rtw -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB -IC:/PROGRA~1/MATLAB/R2012a/toolbox/rtw/rtwdemos -IC:/PROGRA~1/MATLAB/R2012a\sys\lcc\include -Ireferenced_model_includes -I../slprj/grt/_sharedutils -noregistrylookup C:/PROGRA~1/MATLAB/R2012a/rtw/c/grt/grt_main.c
C:/PROGRA~1/MATLAB/R2012a\sys\lcc\bin\lcc -c -Fort_sim.obj -DUSE_RTMODEL -DMODEL=rtwdemo_capi -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0 -DHAVESTDIO -I. -I.. -IC:/PROGRA~1/MATLAB/R2012a\simulink\include -IC:/PROGRA~1/MATLAB/R2012a\extern\include -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\libsrc -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\common -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\tcpip -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\serial -IC:/PROGRA~1/MATLAB/R2012a\rtw\c\src\ext_mode\custom -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB/rtwdemo_capi_grt_rtw -IC:/DOCUME~1/GRAHAM~1/MYDOCU~1/MATLAB -IC:/PROGRA~1/MATLAB/R2012a/toolbox/rtw/rtwdemos -IC:/PROGRA~1/MATLAB/R2012a\sys\lcc\include -Ireferenced_model_includes -I../slprj/grt/_sharedutils -noregistrylookup C:/PROGRA~1/MATLAB/R2012a/rtw/c/src/rt_sim.c
Warning C:/PROGRA~1/MATLAB/R2012a/rtw/c/src/rt_sim.c: 68 static `struct TimingData_Tag td_struct' is not referenced
0 errors, 1 warnings
C:/PROGRA~1/MATLAB/R2012a\sys\lcc\bin\lcclnk -s -LC:/PROGRA~1/MATLAB/R2012a\sys\lcc\lib -o ../rtwdemo_capi.exe rtwdemo_capi.obj rtwdemo_capi_capi.obj rtwdemo_capi_data.obj rtwdemo_capi_datalog.obj grt_main.obj rt_sim.obj @rtwdemo_capi_ref.rsp
rtwdemo_capi_datalog.obj .text: undefined reference to '_rtwCAPI_GetNumSigLogRecords'
rtwdemo_capi_datalog.obj .text: undefined reference to '_rtwCAPI_GetNumStateRecords'
gmake: *** [../rtwdemo_capi.exe] Error 2
### Build procedure for model: 'rtwdemo_capi' aborted due to an error.
Any ideas of what may be wrong? I swapped "Program Files" to "Proga~1" in step 6. Please let me know if you need more information.
  3 Comments
Jose Americo
Jose Americo on 5 Jun 2013
I didn't see any reference to the file in my Makefile. But I added "rtw_modelmap_utils.c" in the additional Source File pane and "$(MATLAB_ROOT)/rtw/c/src/" in the additional directories pane (Include directories). It allowed me tor each the end of the tutorial and generate the "rtwdemo_capi_ModelLog.txt" file.
******** Signal Log File ********
Number of Signals Logged: 2
Number of points (time steps) logged: 1
Time bot_sig1 (Referenced Model) top_sig1
0 70 4
******** State Log File ********
Number of States Logged: 2
Number of points (time steps) logged: 1
Time bot_state (Referenced Model) top_state
0 70 0
It looks like I'm not iterating over time. I added a "printf("%d\n", *tPtr);" at the beginning of capi_UpdateLogging() function - just after the declaration - and I got only a '0' on ML's console. I wonder if there are other files that should be added as well. Thanks for help so far!
Btw, I typed "mex -setup" and I have only " Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2012a\sys\lcc " on my computer. I used this one during the whole process.
Kaustubha Govind
Kaustubha Govind on 5 Jun 2013
Other than rtw_modelmap_utils.c, I also see rt_logging_mmi.c and rt_logging.c being linked against the executable. Perhaps you can try adding these. You need to first install another supported compiler and then run mex -setup.

Sign in to comment.

Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!