www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/07/25/01:08:42

Date: Tue, 25 Jul 1995 07:55:45 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: goncalves AT if DOT usp DOT br
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Problems for linking "libpc.a"

On Mon, 24 Jul 1995 goncalves AT if DOT usp DOT br wrote:

> Hi,
> 
> I cannot use functions from the "libpc.a" library. For instance, for a test
> with the "inportb" function:
[snip]
> I used the following parameters for compilation:
> 
>      gcc -lpc t.c -o t
> 
> and I got the following error message:
> 
>   t.c (.text +0x12): undefined reference to 'inportb'
> 
> Does anyone can help me? It's perhaps a trivial problem, but after reading
> all FAQ's I was not able to solve it.

How can it be?  The FAQ list has an answer for exactly this same problem:

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.

This means that for your case, you should do this:

	gcc -o t t.c -lpc

The latest version of the 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