www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/25/02:42:00

Xref: news2.mv.net comp.os.msdos.djgpp:7851
From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problem with including librairies!
Date: Sun, 25 Aug 1996 01:01:40 -0700
Organization: Three pounds of chaos and a pinch of salt
Lines: 40
Message-ID: <32200864.5956@cs.com>
References: <Pine DOT HPP DOT 3 DOT 91 DOT 960824214355 DOT 17077A-100000 AT merlin DOT si DOT uqam DOT ca>
NNTP-Posting-Host: ppp220.cs.com
Mime-Version: 1.0
To: LEBLANC MARTINE <gj491867 AT er DOT uqam DOT ca>
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

LEBLANC MARTINE wrote:
> 
> I make a program using libgrx20 and libsv, all functions of libgrx20
> include fine and I'm able to use it quite well. The problem popped up
> when I incorporated the functions of libsv.a and the librairie itself for
> modem support. I do include correctly the lib, (#include "libsv.h") and
> add it to the makefile
> 
> gcc libsv.a -O3 -o tacc.exe o/tacc.o o/window.o o/setup.o libgrx20.a

This should look like the following:

gcc -O3 -o tacc.exe o/tacc.o o/window.o o/setup.o -lgrx20 -lsv

You MUST put the libraries to link AFTER all other entries on the
command line.  Also, unless libgrx20.a and libsv.a are in the same
directory as your files, gcc shouldn't be able to find them if
you specify them that way.  Are you seeing 'no such file or directory'
messages when you compile?  If not, then you've put the libraries
in the wrong place - they should go in the /lib directory of your
DJGPP distribution.

BTW, the correct way to link libraries is with the -l directive.
The reason why they need to go last is that ld is a one-pass
linker.  It sees libsv.a first in the command line and knows that
it is a library, so it searches for unresolved externals.  Finding
none, it then goes and links your .o files, only then finding the
external references.

Please read section 8.9 of the FAQ (v2/faq201b.zip); it gives a
much fuller treatment of this subject.  :)

John

-- 
----------------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I     |       fighteer AT cs DOT com              |
| Proud owner of what might one day   |  Plan: To make Bill Gates suffer   |
| be a spectacular MUD...             |  Tagline: <under construction>     |
----------------------------------------------------------------------------

- Raw text -


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