delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/22/11:32:48

From: "ppr. P. V Prok" <ppr DOT p DOT v_prok AT cavalry DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: 2 and more libraries in one project
Date: Mon, 22 Dec 1997 17:14:06 +0200
Organization: NetVision LTD.
Lines: 34
Message-ID: <349E83BC.13C451A6@cavalry.com>
References: <Pine DOT LNX DOT 3 DOT 91 DOT 971222165522 DOT 737B-100000 AT cas3 DOT zlin DOT vutbr DOT cz>
Reply-To: ppr DOT p DOT v_prok AT cavalry DOT com
NNTP-Posting-Host: 194.90.156.130
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Petr Mrazek wrote:

> Hi,
> I had this problem:
>
> Module foo.c contains only int main(void).
> Module libfoo1.c contains function for example void foo1(void)
> Module libfoo2.c function void foo2(void)
>
> I create libraries libfoo1.a and libfoo2.a then add them to project
> foo with module foo.c.
>
> 1. All works fine when main calls foo1 and/or foo2 and this foos don't
> call another foo (from other library) like this:
> main -> foo1
>      \-> foo2
>
> 2. But when I want to call foo1 from main and foo2 from foo1 linker says
> "unresolved external foo2" or something like this.
> ( main -> foo1 -> foo2 )
>
> All works fine when both foo1 and foo2 are in one library.
>
> Is it bug of linker?
>

  Linker searches for functions in libraries ONLY ONCE. So, in order to enable
functions from the second library to call functions from the first one, you have
to use the following command line:

    gcc <flags and objects here>   -lfoo1  -lfoo2  -lfoo1

Gregory

- Raw text -


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