undefined symbol __divsf3

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
nicho2
Posts: 5
Joined: Tue Jul 05, 2016 7:31 am

undefined symbol __divsf3

Post by nicho2 » Mon Nov 29, 2021 8:45 am

Hello, I try to generate a mpy file from a c lib file.

When the makefile link the lib, I have an undefined symbol error

LINK build/iaq_1st_gen.o
qstr vals: py_init_iaq_1st_gen
qstr objs:
LinkError: lib_iaq_1st_gen.o: undefined symbol: __divsf3
make: *** [../../../../../../../_codes/micropython/micropython/py/dynruntime.mk:138: build/iaq_1st_gen.native.mpy] Error 1

Is someone know how to fix this problem?

Thanks

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: undefined symbol __divsf3

Post by dhylands » Mon Nov 29, 2021 6:02 pm

That symbol is provided by libgcc.a. I think it's because you've got a floating point divide in your C code.

https://gcc.gnu.org/onlinedocs/gccint/S ... tines.html

So you've basically got 3 options:

1 - Remove the floating point divide
2 - Link libgcc.a into your code
3 - Write a version of __divsf3 that provides the reqauired functionality

nicho2
Posts: 5
Joined: Tue Jul 05, 2016 7:31 am

Re: undefined symbol __divsf3

Post by nicho2 » Wed Dec 01, 2021 12:35 pm

Thank you,

I hase choose the option 2

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: undefined symbol __divsf3

Post by dhylands » Wed Dec 01, 2021 7:39 pm

And you can use the compiler to determine the correct version of libgcc to use.

Pass in all of the options you would normally use and add the option -print-libgcc-filename and that will give you the name to the libgcc.a This becomes important when there are several different flavours (i.e. hard-float versus soft-float, the arm architecture used, etc).

Post Reply