Can't run C Caller Block example

I am trying to call C-Code from within Simulink, but had no success on my own.
I then tried to run the example to "reverse-engineer" what the required steps are and what I'm missing.
But the example throws the same error and doesn't successfully run either.
I am referring to this example:
I opened it using
openExample('simulink_features/CallCFunctionsUsingCCallerBlockExample')
and tried to run it like regular. I get the following error message:
>> CallCFunctionsUsingCCallerBlockExample
Error using Simulink.importExternalCTypes
Failed to parse custom code. If your custom code uses C++ language syntax, ensure that "Language" is set to "C++". Parser error messages: fatal:
-1, Command-line error: language modes specified are incompatible
The entire stack trace is this:
Error in CallCFunctionsUsingCCallerBlockExample (line 19)
Simulink.importExternalCTypes('my_func.h', 'EnumClass', 'dynamic');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Show complete stack trace
Displaying stack trace:
Error using Simulink.importExternalCTypes
In Simulink.importExternalCTypes
In CallCFunctionsUsingCCallerBlockExample (line 19)
The example is otherwise unmodified. I am running on Linux. Any advice on how to proceed is greatly appreciated.

3 Commenti

Anay
Anay il 22 Ago 2025
Modificato: Anay il 22 Ago 2025
Hi Lukas,
I am using R2024b on a linux machine as well. The example seems to run fine on my end. The error says it failed to parse the custom code. Can you verify that you have not changed the contents of the files?
If possible share more details about your platform
Lukas
Lukas il 22 Ago 2025
Hi Anay,
I am certain that the example is unmodified. I suspect the issue might be in weird interactions between system libraries and matlab-shipped libraries, my system is Arch Linux and there have been issues in the past of library version mismatches.
An example of this that also applied to me was this thread:
But I don't know how to identify the library that is causing issues. If that were possible, maybe the problem could be fixed by preloading/symlinking.
Isha
Isha il 4 Set 2025
Hello,The example seems running fine on my machine.
Library version mismatches between system libraries and MATLAB-shipped libraries can cause issues like this. To identify the problematic library, you can use the “LD_DEBUG=libs” environment variable when launching MATLAB from the terminal.
LD_DEBUG=libs matlab
you can refer this documentation for this environment variable use:
Then, reproduce the error and check the terminal output for library loading paths and conflicts.
Hope this helps.

Accedi per commentare.

Risposte (0)

Categorie

Prodotti

Release

R2024b

Richiesto:

il 20 Ago 2025

Commentato:

il 4 Set 2025

Community Treasure Hunt

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

Start Hunting!

Translated by