error main.c:405: undefined reference to 'rt_InitInfAndNaN'
28 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have this function in my custom tlc file.
this function is working for slx model but it is not working in mdl model from R2024a version and above of matlab
my log for mdl is as below
### Writing header file Simulink_mdl_2024a_types.h
### Writing header file Simulink_mdl_2024a.h
.
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
### Writing header file zero_crossing_types.h
### Writing source file Simulink_mdl_2024a.c
### Writing header file Simulink_mdl_2024a_private.h
### Writing header file rt_nonfinite.h
.
### Writing source file rt_nonfinite.c
### Writing header file rt_defines.h
### Writing header file rtmodel.h
my log for slx is as below
### Writing header file multiword_types.h
### Writing header file zero_crossing_types.h
.
### Writing source file slxtest.c
### Writing header file slxtest_private.h
### Writing header file rt_nonfinite.h
### Writing source file rt_nonfinite.c
### Writing header file rt_defines.h
### Writing header file rtGetInf.h
.
### Writing source file rtGetInf.c
### Writing header file rtGetNaN.h
### Writing source file rtGetNaN.c
### Writing header file rtmodel.h
### Writing source file slxtest_data.c
it is not writing these files
rtgetinf.h, rtgetinf.c , rtgetnan.c amd rtgetnan.h
and it showing the below error in my tool
error main.c:405: undefined reference to 'rt_InitInfAndNaN'
Can you help me with this?
0 Commenti
Risposta accettata
Ruchika Parag
il 8 Lug 2025
Hi @Varsha, this issue happens because MATLAB R2024a and later no longer generate the separate files rtGetInf.c, rtGetNaN.c, or their headers when building code from a .mdl model. Instead, all the related functions, including rt_InitInfAndNaN, are consolidated into a single file called rt_nonfinite.c. Your custom TLC or build process is probably expecting the older structure, which is why you're getting an error.
This doesn’t happen with .slx models because they already follow the updated structure, and rt_nonfinite.c is included automatically in the build.
If you're seeing this error, there are a few ways to work around it. One option is to convert your .mdl model to .slx using save_system('your_model.mdl', 'your_model.slx') and regenerate code from the .slx version. MATLAB handles the newer file structure correctly in that case.
If you need to continue using the .mdl model, you can manually include rt_nonfinite.c and rt_nonfinite.h in your build process. This might require editing your TLC file or makefile to ensure these files are compiled and linked properly.
Another option is to disable non-finite support in the model settings. You can do this by going to Model Configuration Parameters > Code Generation > Interface and unchecking “Support non-finite numbers (NaN or Inf)”. This will remove the reference to rt_InitInfAndNaN entirely, assuming your model doesn’t rely on NaN or Inf values.
In short, this is expected behavior in newer MATLAB releases, and updating your model or build process should resolve the issue.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Target Language Compiler in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!