> how do i add the -l option?
> sorry for asking such a trivial question, i'm new to linux and msp430

You might want to mention what experience you *do* have, because the
tradition of putting floating-point functions in a separate library that
needs to be explicitly linked, and the use of the "-lm" command-line
syntax to do it, dates back to the very first Bell Labs C compiler that
supported floating-point.

So it's not immediately obvious how a person can learn how to program
in C at all and not be familiar with how to invoke the C compiler.


There are two basic ways of turning a .c file into an linked binary:

- All at once:
        cc -o binary source1.c source2.c source3.c
- Separate compilation:
        cc -c source1.c
        cc -c source2.c
        cc -c source3.c
        cc -o binary source1.o source2.o source3.o

But in both cases, the correct place to add "-lm" is at the end of the
"cc -o binary" line, when the multiple sources are combined into
the final binary image.

(I say "cc" rather than "gcc" because this is not at all
GCC-specific.)

Reply via email to