how to solve error saying 'File "<stdio.h>" does not exist' while generating C++ code from simulink having function block that usages abs or real functions?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a Simulink model that contains a matlab function block. This function block usage functions such abs() and real(). While generating code from this simulink model I getting an error:
File "<stdio.h>" does not exist.
When I comment the line that usage real() and abs(), code is generated successfully. Why is that? How to solve this problem?
I am using Ubuntu 14.04 with Matlab Version 9.0 (R2016a) and Simulink Code Version 8.10 (R2016a).
2 Commenti
Ujjwal Gupta
il 30 Ott 2022
Modificato: Ujjwal Gupta
il 31 Ott 2022
I'm facing the similar problem. It happens when I use 'fscanf'. I'm not sure which "stdio.h" file to include in the current directory, as when I include it from the gcc library, which matlab is using for compilation, it throws an error. Following is the error where the simulink coder can't find the library -
### Starting build procedure for: untitled2
### Generating code and artifacts to 'Model specific' folder structure
### Generating code into build folder: /home/ugupta62/GaTech/Research/Simulation/Cov_GTABB/GTABB/untitled2_ert_rtw
The Scope block has the 'SaveFormat' parameter set to 'Dataset'. This format is supported only for normal and accelerator mode simulations. Data will be archived in 'Structure with time' format for this block. [7 similar]
Component: Simulink | Category: Block warning
### Invoking Target Language Compiler on untitled2.rtw
### Using System Target File: /opt/matlab/r2021a/rtw/c/ert/ert.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
...............................................................................
...............................................................................
...............................................................................
...............................................................................
...............................................................................
....
### Writing header file untitled2_types.h
### Writing source file untitled2.cpp
### Writing header file untitled2_private.h
### Writing header file untitled2.h
.
### Writing header file rtmodel.h
### Writing source file untitled2_data.cpp
### Writing source file ert_main.cpp
### TLC code generation complete.
.### Evaluating PostCodeGenCommand specified in the model
ROS Node Archive Creation 1
Elapsed: 2 sec
Creating archive file for model 'untitled2'.
---
### Build procedure for untitled2 aborted due to an error.
Build Summary 1
Elapsed: 0.16 sec
Top model targets built:
Model Action Rebuild Reason
=====================================================================
untitled2 Failed Code generation information file does not exist.
0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 51.262s
File "stdio.h" does not exist.
Ujjwal Gupta
il 31 Ott 2022
Modificato: Ujjwal Gupta
il 31 Ott 2022
Workaround is to use combination of 'fread', 'extractAfter', 'extractBefore', 'str2double', and 'real' instead of 'fscanf' for reading the data, something similar to the follwoing code -
maxBufferSize = 500;
coefdata = zeros(maxBufferSize, 2);
coder.varsize('coefdata')
coder.varsize('before', [1,1000])
coder.varsize('after', [1,1000])
text = fread(fileID, [1,1000000], '*char');
i = 1;
while(1)
text_line = extractBefore(text, newline);
before = extractBefore(text_line, " ");
after = extractAfter(text_line, " ");
coefdata(i,1) = real(str2double(before));
coefdata(i,2) = real(str2double(after));
text = extractAfter(text,newline);
if size(text,1)==0
break
end
i = i+1;
end
Risposte (0)
Vedere anche
Categorie
Scopri di più su Simulink Coder in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!