简体   繁体   中英

Including libraries in the custom code section in Simulink

I'm trying to Include some Libraries, like metis in the custom code library section in Simulink. Do you know what type of libraries Simulink excepts? Must they have the ending .a , .o , .dll or lib ?
And can I include them into my custom c code with #include <metis.h> ?

The library format should match the architecture on which you are going to compile the generated code. So .a or .so for GNU/Linux, .lib for Windows (you usually link against the .lib file not the .dll ), and usually .dylib on Mac. You can also link in object files, (ie .o, .obj ) but typically a software package will build some type of library for you to use.

If you are using any of the functions, types, etc. defined in any of the metis headers, then those headers need to be included in the generated code.

You can add #include "header_name.h" to the settings:

"Configuration Parameters->Simulation Target->Custom Code->Header File"

and:

"Configuration Parameters->Code Generation->Custom Code->Header File"

where header_name.h is replaced with the needed header file's name.

Since this question is tagged MATLAB Coder you can also use coder.cinclude('header_name.h'); in your MATLAB code to generate a #include "header_name.h" in the C code.

You may also need to augment the Include directories settings on the aforementioned Custom Code panes to allow the compiler to locate the headers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM