4

I'm developing program for Cortex-M3. It doesn't have floating point coprocessor. Standard C library can emulate floating point operations, but I don't use it due to its size.

Is there any good and free c library, which can emulate floating point arithmetics, targeted on ARM processors? Currently, when I use floating point operators I have such linkage errors:

undefined reference to `__adddf3'
undefined reference to `__subdf3'
undefined reference to `__divdf3'
undefined reference to `__extendsfdf2'
undefined reference to `__muldf3'

So probably such library should implement them.

asked Feb 2, 2010 at 20:19
2
  • Is the linker pulling in the entire library, or does it have an option to omit any unused library functions? Commented Feb 24, 2010 at 5:25
  • In my first attempts, binary size was huge for embedded application. I'm trying now different approaches, including ones suggested here. For now the main problem it linking with right gcc libraries (hw FP vs sw FP code conflicts) Commented Feb 26, 2010 at 12:06

8 Answers 8

6

Would you not be better off (performance and size wise) using fixed point? For simple arithmetic, this is trivial to implement either directly or with a function interface. If you could bare to use C++, using operator overloading could make the use of fixed almost seamless (at no runtime overhead compared to a C function interface).

If you have more complex requirements (trig, roots etc), a good fixed-point library is presented in this Dr. Dobb's Article.

answered Feb 2, 2010 at 20:39
Sign up to request clarification or add additional context in comments.

Comments

3

If you want to perform your floating arithmetic using built in operators, then you'll need to provide the library routines that the compiler expects, so you'd end up with something that's likely to be as large as the library that came with the compiler.

You likely have the source code to the compiler's floating support routines, so if you want to look at them to see if you can improve them that's probably your best chance. If you don't think that'll work for whatever reason, you should talk to your compiler vendor about the requirements the compiler expects of the floating support routines and the best way to replace the vendor's library.

If you want to circumvent the compiler's requirements, you'll probably need to avoid using the built in operators and perform you arithmetic using explicit function calls. I have no experience with 3rd party floating point library routines, so unfortunately I can't point you to an possible good alternatives.

answered Feb 2, 2010 at 20:34

Comments

1

Those should be defined in the runtime support library for your compiler. Those names look like the floating-point functions from libgcc (the support library for gcc), which is pretty small. You should be able to pull in those functions by setting your link flags appropriately.

answered Feb 2, 2010 at 20:29

Comments

1

Perhaps newlib would be useful here? It can be a pain to set up the toolchain, but I've had success in reducing embedded flash usage versus gcc and its standard library.

answered Feb 25, 2010 at 20:38

Comments

0

Any static linker worth its salt is going to remove unused calls. This is particularly true for embedded compilers.

answered Feb 2, 2010 at 20:37

Comments

0

gcc has all of those functions, there is gcc build voodoo (multilib, thumb, thumb2, and soft float) you can use to have that automatically have it show up. I have years ago given up and just go grab the files from the gcc sources trim them to a clean source and just build them into my projects. Years ago looking at a commercial compiler or two then looking at newlib and gcc, at least at the time they were all using pretty much the same math library. I want to say it was from Sun.

answered Feb 2, 2010 at 22:39

Comments

0

Assuming your using gcc try compiling with the -static-libgcc flag and checking the final binary size. I don't know if the linker will optimize out the unused calls but I think it will.

answered Feb 3, 2010 at 17:55

Comments

0

All the below message represent some arithmetic operation undefined reference to __adddf3' undefined reference to__subdf3' undefined reference to __divdf3' undefined reference to__extendsfdf2' undefined reference to `__muldf3'

So while linking compiler will give linking error if you are doing some arthamatic operation in two different data type. For example: Float x; float y;

y = x * 0.45;

So if you compile this code while linking it will give you below message undefined reference to `__muldf3'

To resolve this specify the "0.45" explicitly to float y = x * 0.45F;

Most of the time this type of linking error comes when you are using c++ compiler to compile c file.

answered Mar 7, 2019 at 10:06

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.