www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/10/15/05:56:42

Date: Sun, 15 Oct 1995 11:06:20 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Ahmad Hasnah <hasnahm AT charlie DOT acc DOT iit DOT edu>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: gcc question

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019