Page 1 of 1

undefined symbol __divsf3

Posted: Mon Nov 29, 2021 8:45 am
by nicho2
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

Re: undefined symbol __divsf3

Posted: Mon Nov 29, 2021 6:02 pm
by dhylands
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

Re: undefined symbol __divsf3

Posted: Wed Dec 01, 2021 12:35 pm
by nicho2
Thank you,

I hase choose the option 2

Re: undefined symbol __divsf3

Posted: Wed Dec 01, 2021 7:39 pm
by dhylands
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).