Mail Archives: djgpp/1995/07/25/01:08:42
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 -