Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By noqosoyo
#9911 The math package within NodeMCU is pretty incomplete, so i resorted to build withing the pwm.c module located in app/modules the three mathematical functions i'm gonna need: just atan, sqrt and pow.

Inside pwm.c i got this:

int lpwm_sqrt( lua_State* L )
{
lua_pushnumber( L, sqrt(64) );
return 1;
}

Now, i can compile it and make it print a value if i statically call the function pwm.sqrt() from the Node console. But, if I change the argument of the sqrt() to a variable, the compiler tells me «(...) undefined reference to `sqrt' (...)».
Including math.h won't help and adding -lm to the linker options won't either.

Has anyone experienced a similar situation?
User avatar
By jcmvbkbc
#10012
noqosoyo wrote:i can compile it and make it print a value if i statically call the function pwm.sqrt() from the Node console. But, if I change the argument of the sqrt() to a variable, the compiler tells me «(...) undefined reference to `sqrt' (...)».
Including math.h won't help and adding -lm to the linker options won't either.

Sounds like libc misconfiguration. I'll have a look.
User avatar
By jcmvbkbc
#13861
jcmvbkbc wrote:
noqosoyo wrote:i can compile it and make it print a value if i statically call the function pwm.sqrt() from the Node console. But, if I change the argument of the sqrt() to a variable, the compiler tells me «(...) undefined reference to `sqrt' (...)».
Including math.h won't help and adding -lm to the linker options won't either.

Sounds like libc misconfiguration. I'll have a look.

xtensa newlib and crosstool-NG lx106-g++ branch are now fixed.