Using math.h functions in Simulink S-function builder
Mostrar comentarios más antiguos
Hi,
I'm trying to create a design with some S-Functions blocks coded in C. I'm using the S-Function Builder and I trying to use some math.h functions. I included math.h in my libraries, but these functions are not referenced.
These are the errors that I got:
Writing library for code.mexw32
PATH\code_wrapper.obj .text: undefined reference to '_lroundf'
PATH\code_wrapper.obj .text: undefined reference to '_fabsf'
I would be glad if you can tell me what is the problem.
Thank you.
Respuestas (1)
Walter Roberson
el 22 de Feb. de 2017
0 votos
You have not linked against the math library. On OS-X and Linux systems, that would be by adding the option "-lm" to the mex command line (the name of the library on those systems is "m").
My reading suggests that if you were using Visual Studio that it would already have the math library built in to the standard libraries. Are you possibly using MinGW ?
5 comentarios
Pedro Bernardes
el 22 de Feb. de 2017
Walter Roberson
el 22 de Feb. de 2017
Editada: Walter Roberson
el 22 de Feb. de 2017
What compiler have you configured?
Pedro Bernardes
el 22 de Feb. de 2017
Walter Roberson
el 22 de Feb. de 2017
Unfortunately I do not know much about lcc-32.
When I look at https://pubs.usgs.gov/sir/2008/5065/USGS_AR_LowflowGUI/LFArk1_mcr/LFArk1_BEB1E7AFA58B476C104CA972EFDF3CB1/compopts.bat which indicates it sets up for using lcc with the C math library, I do not see any explicit math library.
Pedro Bernardes
el 23 de Feb. de 2017
Editada: Pedro Bernardes
el 23 de Feb. de 2017
Categorías
Más información sobre Block and Blockset Authoring en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!