www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/06/20/13:00:57

Date: Tue, 20 Jun 1995 18:24:51 +0300
From: eliz AT is DOT elta DOT co DOT il (Eli Zaretskii)
To: gmoscho AT alexander DOT cc DOT ece DOT ntua DOT gr
Subject: Re: Q
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

> using the following command :
>
>  gcc -s hello.cc
>
> and i got the following error messages :
>
> iostream.cc (...) : undefined reference to '_ctype_'
> stdstrbufs.cc (...) : undefined reference '_iob_'
> iovfscanf.cc (...) : undefined reference '_ctype_'

This is explained in the DJGPP FAQ list (available as faq102.zip
from the same place you get DJGPP).  Note that this FAQ is for
v1.x; v2.0 doesn't have -lpc or -lm, so these shouldn't give you
any problesm, but -lgpp should still be given.  This is what the
FAQ says:

 
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).
 
8.11  Q: I put all the libraries in the above order, but the linker still
         can't find some C++ functions from complex.h and iostream.
      A: These functions are declared inline.  However, GCC won't inline
         them unless you compile with optimizations enabled, so it tries
         to find the compiled version of the functions in the library.
         Workaround: compile with -O.

- Raw text -


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