Simulink Coder - Cannot open include file: 'nesl_rtw.h'
Show older comments
I am using Simulink Coder to compile my simulink model into a shared library (embedded target) which I then try to load into MATLAB using coder.loadlibrary. Upon executing the following command, I get an error:
libModelPath = fullfile(pwd, 'mylib_ert_shrlib_rtw');
libSimulinkPath = fullfile(matlabroot, 'simulink', 'include');
hfile = fullfile(libModelPath, 'mylib.h');
coder.loadlibrary('mylib_win64', hfile, ...
'includepath', libModelPath, ...
'includepath', libSimulinkPath, ...
'mfilename', 'testfile', ...
'alias', 'mylibrary')
The error I get is:
coder.loadlibrary('mylib, hfile)
Error using loadlibrary (line 447)
Failed to preprocess the input file.
Output from preprocessor is:'mylib.h
C:\Users\[...]\'mylib_ert_shrlib_rtw\'mylib.h(28)
: fatal error C1083: Cannot open include file: 'nesl_rtw.h': No such file or directory
Lines 18-30 of mylib.h:
#ifndef RTW_HEADER_mylib_h_
#define RTW_HEADER_mylib_h_
#include <math.h>
#include <float.h>
#include <string.h>
#ifndef mylib_COMMON_INCLUDES_
# define mylib_COMMON_INCLUDES_
#include "rtwtypes.h"
#include "rtw_continuous.h"
#include "rtw_solver.h"
#include "nesl_rtw.h"
#include "mylib_8bed9f9f_gateway.h"
#endif /* mylib_COMMON_INCLUDES_ */
A quick search of my system doesn't produce a file named nesl_rtw.h.
Answers (3)
zijin wang
on 26 Apr 2017
0 votes
你好,我也遇到相同的问题,想问你解决没有,谢谢
Michael Burke
on 4 Jan 2019
0 votes
The nesl_rtw.h file is part of the
<MATLAB_ROOT>/toolbox/physmod/simscape/engine/sli/<ARCH>/
Directory where <ARCH> is the architecture you are running on the "ARCH" will change.
Note: You may need to include additional directories. You can search the MATLAB path using the internal file search tool
nigel
on 19 Aug 2025
0 votes
I found it in the following directory (I have 2024b running on Windows 64-bit):
C:\Program Files\MATLAB\R2024b\extern\physmod\win64\ssc_sli\include\nesl_rtw.h
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!