Where is math.h?
Where is math.h?
Hi, I try to use sqrt() and atan() functions. Where they are in IDF library? Which header file declares them?
Re: Where is math.h?
Hi valery,
math.h is installed as part of the libc (newlib), so on recent ESP-IDF versions it's installed alongside the toolchain (gcc) not inside ESP-IDF itself. If you look around the location where the toolchain is installed then you can find it (note that recent versions of ESP-IDF ship a few different newlib variants with different compile options so there may be multiple toolchain subdirectories with different newlibs).
However, you may not need to find this header. All the libc standard functions in math.h should be present and the header should include cleanly, and the functions should compile and link correctly.
If you're having a specific problem getting something to work, please post some more details and the error message and we'll try to help.
math.h is installed as part of the libc (newlib), so on recent ESP-IDF versions it's installed alongside the toolchain (gcc) not inside ESP-IDF itself. If you look around the location where the toolchain is installed then you can find it (note that recent versions of ESP-IDF ship a few different newlib variants with different compile options so there may be multiple toolchain subdirectories with different newlibs).
However, you may not need to find this header. All the libc standard functions in math.h should be present and the header should include cleanly, and the functions should compile and link correctly.
If you're having a specific problem getting something to work, please post some more details and the error message and we'll try to help.
Re: Where is math.h?
Thank you. Is there a way to find location of a header file without IDE? Some time just want to look inside a header file, and wondering if IDF has some analog to 'whereis' tool.
Re: Where is math.h?
I have a similar problem. When I add math.h I get warning "The math library must be enabled by CONFIG_NEWLIB_LIBC to be included in the build. Due to this fact, I added sdkconfig.defaults file where I added CONFIG_NEWLIB_LIBC=y and instead of <math.h> I include <newlib.h>. I try to use math functions but are not visible. Please let me know what I have to do?
Re: Where is math.h?
Hi SamoESP, what do you use Arduino or ESP-IDF? Also what version? I cannot reproduce your problem. ESP32 ROM and ESP-IDF use Newlib instead of glibc as their standard C library, it is always included. You should be able to just do `#include <math.h>`.
Re: Where is math.h?
Hello,
despite post has 2 years, I faced same issue. in the ULP co-processor, I manage to use some math function with a constant but not with a variable "sqrt(4) is ok but sqrt(myvariable) is creating compilation error : undefined reference to `sqrt'.
This works perfectly on main program, just not when it is in ULP co-processor.
I use PIO with ESP-IDF 5.4.1.
I tried to add this CONFIG_NEWLIB_LIBC, but not working neither.
Any idea how to solve ?
despite post has 2 years, I faced same issue. in the ULP co-processor, I manage to use some math function with a constant but not with a variable "sqrt(4) is ok but sqrt(myvariable) is creating compilation error : undefined reference to `sqrt'.
This works perfectly on main program, just not when it is in ULP co-processor.
I use PIO with ESP-IDF 5.4.1.
I tried to add this CONFIG_NEWLIB_LIBC, but not working neither.
Any idea how to solve ?
Who is online
Users browsing this forum: Barkrowler, Bing [Bot] and 6 guests
