Unable to load simple shared library (.so) in simulink
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Joshua
el 18 de Feb. de 2025
Respondida: Snehal
el 21 de Feb. de 2025
Edit: I noticed the following message on my console:
Warning: gcc version '4.8.5' not supported. See https://www.mathworks.com/support/compilers/current_release.
> In createCustomCodeDLL
In createCustomCodeDLL
In genCustomCodeLib
In genCustomCodeLib
In cgxeprivate
In buildCustomCodeForModel
In slccprivate
In SLCC.configset.ccParseCCBtnCallback
In SLCC.configset.ccParseCCBtnCallback
In configset.internal.data.ConfigSetAdapter/dialogCallback
In configset.dialog.HTMLView/callback
In configset.dialog.HTMLView/actionDispatcher
In configset.dialog.HTMLView.init>@(varargin)obj.actionDispatcher(varargin{:})
In configset.dialog.Connector/callback
In configset.dialog.Connector>@(varargin)obj.callback(varargin{:})
In message.internal.executeCallback
Warning: gcc version '4.8.5' not supported. See https://www.mathworks.com/support/compilers/current_release.
> In createCustomCodeDLL
In createCustomCodeDLL
In genCustomCodeLib
In genCustomCodeLib
In cgxeprivate
In buildCustomCodeForModel
In slccprivate
In SLCC.configset.ccParseCCBtnCallback
In SLCC.configset.ccParseCCBtnCallback
In configset.internal.data.ConfigSetAdapter/dialogCallback
In configset.dialog.HTMLView/callback
In configset.dialog.HTMLView/actionDispatcher
In configset.dialog.HTMLView.init>@(varargin)obj.actionDispatcher(varargin{:})
In configset.dialog.Connector/callback
In configset.dialog.Connector>@(varargin)obj.callback(varargin{:})
In message.internal.executeCallback
I suspect that my issue may be related... If someone can confirm and let me know what the newest version of matlab/simulink that I can use with my current setup is (pretty sure it's 2013b), then I can downgrade and try my code there instead.
I am trying to call a very simple C library function from within simulink using a 'c caller block'. The function is called 'increment' and takes an int as an argument, increments it by one, and returns it. When I attempt to 'validate custom code' I get the following error:
Parsing custom code in model 'increment' successful. The following functions were imported successfully:
increment
Component:Simulink | Category:Custom Code
Failed to load custom code simulation library:/home/deblonj/Desktop/matlab/slprj/_slcc/wii51jUTzsCFiYyRvDyqeB/wii51jUTzsCFiYyRvDyqeB_cclib.so
I am running R2022a on CentOS 7.6.1810 with gcc v4.8.5-44, and I am not able to upgrade.
here is the source for test.h:
int increment(int value);
here is the source for test.c:
int increment(int value)
{
return value++;
}
Since I got the message indicating that the custom code was imported successfully message, I believe my configuration for the custom code is correct, per the documentation.
I observe that matlab/simulink is building a separate library (wii51jUTzsCFiYyRvDyqeB_cclib.so) for some reason, and storing it at
/home/deblonj/slprj/_slcc/wii51jUTzsCFiYyRvDyqeB
LD_LIBRARY_PATH=/home/deblonj/slprj/_slcc/wii51jUTzsCFiYyRvDyqeB matlab
but this did not change anything. I'm pretty much out of ideas and would like some guidance about how to proceed.
Thanks in advance,
Josh
0 comentarios
Respuesta aceptada
Más respuestas (1)
Snehal
el 21 de Feb. de 2025
My understanding is that you are trying to create a custom shared library in version R2022a of Simulink/MATLAB using the compiler: GCC v4.8.5-44.
The console messages that you get when attempting to ‘validate custom code’ in CentOS 7.6.1810 indicate two things:
- The message "Parsing custom code in model 'increment' successful" indicates that Simulink was able to understand and interpret the function declarations correctly. This means the header files were correctly formatted and accessible
- The error "Failed to load custom code simulation library" suggests that while the parsing step was successful, the compilation step (handled by GCC) failed, or the resulting library could not be loaded
The ‘LD_LIBRARY_PATH’ method you tried is typically for runtime linking issues, but the core problem seems to be with the initial compilation due to GCC incompatibility.
Also, the presence of the ‘.so’ file (separate library ‘wii51jUTzsCFiYyRvDyqeB_cclib.so’) suggests that GCC is invoked by Simulink to compile the C code, but it doesn't guarantee that the compilation was error-free. There may have been warnings or errors during compilation that affect the usability of the library.
The documentation:
indicates that while support for GCC C/C++ 4.7.x was initially set to be replaced in a future release after R2016a, it was officially upgraded to GCC C/C++ 4.9 starting with the R2016b release.
Therefore, the latest version of MATLAB/Simulink that can be used with GCC v4.8.5 is R2016a, and you may consider changing your MATLAB version from R2022a to R2016a given that you are unable to upgrade the GCC version.
I hope this helps.
0 comentarios
Ver también
Categorías
Más información sobre C Shared Library Integration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!