Page 1 of 1
Where is math.h?
Posted: Sun May 03, 2020 12:25 pm
by valery
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?
Posted: Mon May 04, 2020 12:02 am
by ESP_Angus
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.
Re: Where is math.h?
Posted: Wed May 13, 2020 5:42 pm
by valery
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?
Posted: Mon Oct 02, 2023 11:34 am
by SamoESP
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?
Posted: Fri Oct 06, 2023 1:09 pm
by ESP_adokitkat
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>`.