Where is math.h?

valery
Posts: 5
Joined: Sun May 03, 2020 12:20 pm

Where is math.h?

Postby valery » Sun May 03, 2020 12:25 pm

Hi, I try to use sqrt() and atan() functions. Where they are in IDF library? Which header file declares them?

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Where is math.h?

Postby ESP_Angus » Mon May 04, 2020 12:02 am

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.

valery
Posts: 5
Joined: Sun May 03, 2020 12:20 pm

Re: Where is math.h?

Postby valery » Wed May 13, 2020 5:42 pm

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.

SamoESP
Posts: 1
Joined: Mon Oct 02, 2023 11:27 am

Re: Where is math.h?

Postby SamoESP » Mon Oct 02, 2023 11:34 am

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?

ESP_adokitkat
Posts: 52
Joined: Thu Jun 22, 2023 12:50 pm

Re: Where is math.h?

Postby ESP_adokitkat » Fri Oct 06, 2023 1:09 pm

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>`.

Who is online

Users browsing this forum: rsimpsonbusa and 86 guests