Thread: Including library's

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    52

    Including library's

    Dear programmers,

    I've made a signal generator on a ARM processor. In the sourcecode I include <math.h> so I can use the sin() function. This is the only function I use from math.h Does the compiler include all the functions in the .hex (and makes it realy realy big) or only the one witch I use(the sin function) ?

    kind regards,

    Libpgeak

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    typically the linker will only pull the functions it needs or at worst the entire object file that contains the function, depending on the linker and how the library is organized. but it would be surprising if a linker pulled in the entire library. however, in the case of an ARM processor, if it doesn't have hardware floating point, it may be that it has to pull in an entire low level software floating point library to support any float operations such as sin.

    the way to see what happens is to generate the linker map file with and without calling the sin function and compare the two to see what extra is in there.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Generally no, not everything in the math library will be included. But it really depends on which compiler you use, and how the object files and libraries are built to begin with. Different compilers, library formats and executable formats have different capabilities in this regard. Check the documentation for whatever you're using to be sure.

    Some of the large size may be "startup" and "cleanup" code, i.e. stuff that happens before you get to your main function or after it's done. There's a lot that goes into bringing up even a simple embedded system without a "proper" OS (I assume this is your scenario, given the .hex file). You often have to initialize power systems, IO systems, A/D converters, etc.

  4. #4
    Registered User
    Join Date
    Sep 2011
    Posts
    52
    Thanks guys! When I pull the <math.h> library out of it, the file doesn't shrink down. So I think the linker is smart enough. @anduril462 There is in this project no OS included, becouse I'ts a DSP project. A OS will only slow down everything and decrease your maximum frequency! But when I do use a OS (like MicroC) I still upload a .hex file to the ARM processor!

    Thanks,

    Libpgeak

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-08-2012, 10:23 PM
  2. including a static library!
    By hmd in forum C Programming
    Replies: 1
    Last Post: 04-06-2008, 03:41 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Replies: 19
    Last Post: 01-12-2006, 11:04 AM
  5. Including Library...
    By Da-Spit in forum Game Programming
    Replies: 2
    Last Post: 05-29-2002, 12:22 AM