Simulink compilation doesn't find string.h

20 views (last 30 days)
syl1446
syl1446 on 2 Oct 2019
Answered: chen junbing on 15 May 2024
When trying to compile a Simulink model, I get the error: "C1083: Cannot open include file: 'string.h': No such file or directory" during the compilation of one of the sub-models. The header is located in "C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt" but Matlab doesn't seem to be able to find it. I've tried to add this path to the includes search path by adding it to 'Model Configuration Parameters > Simulation Target > Include directories'. I've also tried to pass it directly to the toolchain by choosing 'Specify' for "Model Configuration Parameters > Code Generation > Build configuration" and adding the path prepended by '-I' (capital i) to 'C Compiler' and 'C++ Compiler'. None of these attempts worked.
How can I tell Simulink where to look for this file ?
I use Matlab 2018b on Windows 7 with Visual C++ 2017 v15.0.
Thanks

Answers (3)

Chaitanya Mallela
Chaitanya Mallela on 30 Dec 2020
you can specify the C header file for simulation in the Simulation Target pane of the Model Configuration Parameters dialog box.
#include <string.h>
To access C source and header files outside your working folder, list the path in the Simulation Target pane, in the Include Directories text box.

chen junbing
chen junbing on 15 May 2024
Hello:
Has this problem been solved? I also encountered a similar problem with the error message as follows:
### Starting build procedure for: TestLinUnpack ### Generating code and artifacts to 'Model specific' folder structure ### Generating code into build folder: E:\Test_LINUNPACK\TestLinUnpack_ert_rtw ### Invoking Target Language Compiler on TestLinUnpack.rtw ### Using System Target File: D:\matlab2022b\rtw\c\ert\ert.tlc ### Loading TLC function libraries ### Generating TLC interface API for custom data ### Initial pass through model to cache user defined code . ### Caching model source code ### Writing header file TestLinUnpack_types.h . ### Writing header file TestLinUnpack.h ### Writing header file rtwtypes.h ### Writing source file TestLinUnpack.c ### Writing header file TestLinUnpack_private.h ### Writing source file TestLinUnpack_data.c . ### Writing source file ert_main.c ### TLC code generation complete (took 3.603s). ### Saving binary information cache. ### Using toolchain: MinGW64 | gmake (64-bit Windows)
Warning: The precompiled library 'D:\matlab2022b\toolbox\slrealtime\simulink\blocks\dist\win64\lib\libecatinterface_ert_mingw64.lib' does not exist. Generating makefile rules to build the library.
6 similar
### Creating 'E:\Test_LINUNPACK\TestLinUnpack_ert_rtw\TestLinUnpack.mk' ... ### Building 'TestLinUnpack': "D:\matlab2022b\bin\win64\gmake" -f TestLinUnpack.mk all E:\Test_LINUNPACK\TestLinUnpack_ert_rtw>call "setup_mingw.bat" E:\Test_LINUNPACK\TestLinUnpack_ert_rtw>set "MINGW_ROOT=C:\PROGRA~3\MATLAB\SUPPOR~1\R2022b\3P778C~1.INS\MINGW_~1.INS\bin" E:\Test_LINUNPACK\TestLinUnpack_ert_rtw>cd . E:\Test_LINUNPACK\TestLinUnpack_ert_rtw>if "all" == "" ("D:\matlab2022b\bin\win64\gmake" -f TestLinUnpack.mk all ) else ("D:\matlab2022b\bin\win64\gmake" -f TestLinUnpack.mk all ) "C:\PROGRA~3\MATLAB\SUPPOR~1\R2022b\3P778C~1.INS\MINGW_~1.INS\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DMODEL=TestLinUnpack -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @TestLinUnpack_comp.rsp -o "TestLinUnpack.obj" "E:/Test_LINUNPACK/TestLinUnpack_ert_rtw/TestLinUnpack.c" E:/Test_LINUNPACK/TestLinUnpack_ert_rtw/TestLinUnpack.c: In function 'TestLinUnpack_step':
void *dataPort = TestLinUnpack_ConstP.Constant_Value; ^~~~~~~~~~~~~~~~~~~~
memcpy(data,dataPort,8); ^~~~~~
E:/Test_LINUNPACK/TestLinUnpack_ert_rtw/TestLinUnpack.c:40:5: note: include '<string.h>' or provide a declaration of 'memcpy' "C:\PROGRA~3\MATLAB\SUPPOR~1\R2022b\3P778C~1.INS\MINGW_~1.INS\bin/gcc" -c -fwrapv -m64 -O0 -msse2 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DMODEL=TestLinUnpack -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @TestLinUnpack_comp.rsp -o "TestLinUnpack_data.obj" "E:/Test_LINUNPACK/TestLinUnpack_ert_rtw/TestLinUnpack_data.c" gmake: *** No rule to make target `libecatinterface.a', needed by `../TestLinUnpack.exe'. Stop. E:\Test_LINUNPACK\TestLinUnpack_ert_rtw>echo The make command returned an error of 2 The make command returned an error of 2 E:\Test_LINUNPACK\TestLinUnpack_ert_rtw>exit /B 1 ### Build procedure for TestLinUnpack aborted due to an error.
How can I solve it,Thank you!

chen junbing
chen junbing on 15 May 2024
This is my model,matlab ver is 2022b.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!