Mail Archives: djgpp/1995/10/15/05:56:42
On Fri, 13 Oct 1995, Ahmad Hasnah wrote:
> I hope that someone can help me. I have two question. The first one is I tried
> to use sqrt function in my program. when I compile my program it send back an
> error massage that sqrt undefined or un resolved referance eventhough I
> had included the math.h header file. I hope that there is a soluation
> to this problem.
Yes, there is, and it's in the FAQ:
8.8 Q: When I compile my program, the linker complains about mathematical
functions, although I did #include <math.h>.
Q: The linker complains it cannot find cprintf function.
Q: Why do I get so many unresolved symbols when linking C++ programs?
A: By default, gcc instructs the linker to only look in two libraries:
libgcc.a and libc.a. Some functions aren't included there, so the
linker can't find them. For math functions, like sin() and exp(),
append ``-lm'' to the gcc command line; for pc-specific
functions, like cputs() and cprintf() append ``-lpc''; to use C++
classes append ``-lgpp''. GPL library routines, like obstack and
regex packages are in libgpl.a library; append ``-lgpl'' to use
them.
Note that some C++ classes use math routines, so the -lm should
be given after the -lgplus.
The latest version of the DJGPP FAQ list is available as faq102.zip from
the same place you get DJGPP.
- Raw text -