-->
Page 1 of 1

Trying to compile NodeMCU (LUA) with math support

PostPosted: Mon Feb 16, 2015 7:02 am
by noqosoyo
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?

Re: Trying to compile NodeMCU (LUA) with math support

PostPosted: Tue Feb 17, 2015 9:40 am
by jcmvbkbc
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.

Re: Trying to compile NodeMCU (LUA) with math support

PostPosted: Wed Apr 08, 2015 7:32 am
by jcmvbkbc
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.