www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/06/01:17:20

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199606060457.AA153037027@relay1.geis.com>
Date: Thu, 6 Jun 96 04:32:00 UTC 0000
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Little problem with compil

Reply to message 0310979    from MISTRYC AT ECF DOT T on 06/05/96 12:47PM


>I have a program which uses a few math functions from the include file,
>and I have the line "#include <math.h>" in my code, and I compile it with
>the command "gcc -lm progname.c" ;  but I still get an error message
>something like undefined reference to "pow" (the function I'm using).

That should read:  "gcc progname.c -lm".  Because the linker looks at
things in the order it sees them, it looks at libm.a first, doesn't see
anything
that it needs, and _then_ looks at your program and is unable to resolve
the reference to pow().  Always put link commands at the _end_ of your
command line.

>The program itself works because I tried it on my unix account at school,
>it just dosn't compile on my PC.  I installed gcc, set the environment
>variables, and modified my path.  Am I missing something?

You may also want to tell gcc what to call the executable it creates,
because by default you get aout and aout.exe, which are really dumb
filenames.  Try the following command line:

gcc -Wall -g -o progname progname.c -lm

The "-Wall" tells gcc to output a large variety of useful warnings.
The "-g" tells gcc to include debugging information in your program, which
is essential if you want to use any of the debugging tools that DJGPP
provides, like fsdb, gdb, or edebug32.
The "-o progname" tells gcc to output files called "progname" and
"progname.exe" instead of "aout" and "aout.exe".

Brief question for DJ or Eli:  Why the heck doesn't gcc output "coff" instead
of "aout".  The files are in coff format, right?  This makes no sense.  :)

John

- Raw text -


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