Using the -l option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was trying to compile a program that used a function from math.h and couldn't
get it to work, until I found out that I needed to use "gcc -lm test.c", and
#include <math.h> in the program wasn't enough.  I know from the documentation
that -lxxxx searches the library named xxxx when linking, but how do I know
what library to name?  I wouldn't have guessed that I need -lm when I'm using
math.h, and I'm wondering what the chances are that I'll run into this problem
again when I need some other library.  I'm also using time.h in a program, but
I only needed to use an #include statement, with nothing extra on the command
line.

Phil Carter

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux