I'm trying to build the blinky example where I added a simple cos() and included math.h, with a toolchain based on the esp-open-sdk toolchain, and using the ESP8266_NONOS_SDK-2.2.0.
However it fails at linking stage because of the cos() with errors like these:
.../xtensa-lx106-elf/lib/libm.a(lib_a-k_rem_pio2.o):(.literal+0x1c): undefined reference to '__gedf2'
I tried several linker flags as -lm, -lmirom, etc at various position, and even the libmirom.a from the RTOS SDK as suggested here (https://bbs.espressif.com/viewtopic.php ... math#p3254) but with same error. And according to this same post the math library IS implemented.
So, how do you link or use the math library ?
Code: Select all
[b]-Wl,[/b]--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -lhal -lc -lgcc -ldriver [b]-lm[/b] [b]-Wl,--end-group[/b]
Moreover, the fmod() and fmof() are relying by default on the the libgcc function _ieee754_remainder() which is not implemented by the XTensa compiler what break the compilation. To fix it, you can edit crosstool-NG/.build/src/newlib-2.0.0/newlib/libm/math/ef_fmod.c and change the #ifdef from 1 to 0 to enable the native version of fmod() that is independant from _ieee754_remainder() and recompile the SDK.
With this two fixes, I got a fully functionnal math library.
Who is online
Users browsing this forum: No registered users and 4 guests
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
We also have a RTOS version and a MESH version too!
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!