www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/07/20/13:13:50

Date: Thu, 20 Jul 1995 19:02:38 +0300
From: eliz AT is DOT elta DOT co DOT il (Eli Zaretskii)
To: lennond AT luigistoaster DOT pds DOT charlotte DOT nc DOT us
Subject: Re: Missing Functions in Standard Libraries
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

> I have all the standard libraries for djgpp, at least all the ones I can 
> find, but when I try to compile a program it seems that the libraries are 
> missing various calls.  For instance, I have not been able to find a 
> library file containing the ioctl, inp, and outp functions which I 
> thought were pretty standard.  The library files I have now are C, DBG, 

First, not all of the functions you are used to on a PC are ``standard'',
so not all of them must be there (e.g., ioctl() isn't, I think).  The DJGPP
FAQ list (available as faq102.zip from the same place you get DJGPP),
section 8.9 explains how to know which functions are in which library.

The correct way of convincing the linker to get all the functions you need
is explained in the FAQ list, sections 8.8 and 8.10:
 
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.
 
8.10  Q: I give all the libraries to gcc, but I still get unresolved
         externals when I link.  What gives?
      A: Ld is a one-pass linker, it only scans each library once looking
         for unresolved externals it saw UNTIL THAT POINT.  This means the
         relative position of object files and library names on the
         command line is significant.  You should put all the libraries
         AFTER all the object files, and in this order:
 
                      -lgpp -lgpl -lm -lpc
 
         If you have any libraries of your own, put them BEFORE the above
         system libraries.
 
         If your installation tree is different from the default, i.e., if
         you keep the libraries NOT in the default lib/ subdirectory, then
         you should add that directory to the line in the [gcc] section of
         your DJGPP.ENV file which starts with LIBRARY_PATH, or put into
         your environment a variable called LIBRARY_PATH and point it to
         the directory where you keep the libraries.  Note that if you
         invoke the linker by itself (not through the gcc driver), then
         DJGPP.ENV must have an [ld] section which sets LIBRARY_PATH, or
         else ld.exe won't see that variable in its environment, unless
         you put it into the environment yourself (make sure you have
         enough available environment space).
 

- Raw text -


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