Cannot find header file in Simulink Coder
23 次查看(过去 30 天)
显示 更早的评论
I'm using the C Function block in Simulink to import custom C code into my model. Most of the standard C libraries I include Simulink is able to locate them such as stdint.h and stdio.h. However, whenever I include <sys/mman.h> Simulink reports that it "cannot open source file "sys/mman.h"". In my Code Generation settings I have ARM Development Studio Altera Edition (DS-5 AE) selected as the toolchain. Where is the Simulink coder searching for the standard header files and why is this particular one missing?
0 个评论
回答(2 个)
Divyajyoti Nayak
2025-3-24
I think Simulink is unable to find the 'sys/mman.h' header file because it is only found in UNIX environments, so Simulink might consider it a custom header file in your workspace. To configure Simulink for your custom code, this documentation may be of help:
0 个评论
Adit
2025-8-8,9:12
Hello John,
The reason Simulink cannot find the sys/mman.h header file is that this header is specific to UNIX/POSIX systems and is not available on all platforms or toolchains, especially those targeting embedded systems like the ARM Development Studio Altera Edition (DS-5 AE). Most embedded toolchains do not provide POSIX headers such as sys/mman.h.
Simulink searches for header files in the following locations:
- The current working folder.
- The folder containing your model.
- Any directories you add under Configuration Parameters > Code Generation > Custom Code > Include directories.
- Folders on the MATLAB path (excluding toolbox folders).
“You can specify sources of custom C/C++ code for your Simulink® model. These sources can include header files, source code files, and precompiled library files... To configure your model to access custom code, specify the folder paths that contain custom header files in the Include directories parameter.”
If your toolchain does not provide sys/mman.h (as is the case for DS-5 AE), Simulink will not be able to find it, even if you specify additional include directories.
If you require POSIX-specific functionality, you will need to either:
- Use a toolchain that targets a POSIX-compliant operating system (such as GCC for Linux), or
- Refactor your code to avoid using POSIX-specific headers and functions.
For more information on configuring custom code in Simulink, see the MathWorks documentation:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!