Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-ID: <20000502152335.9635.qmail@web115.yahoomail.com> Date: Tue, 2 May 2000 08:23:35 -0700 (PDT) From: Earnie Boyd Reply-To: earnie_boyd AT yahoo DOT com Subject: Re: Newbie: libProblem.a To: Bobak Csaba , cygwin AT sourceware DOT cygnus DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii --- Bobak Csaba wrote: > Hi all! > > After searching the archives I have to ask this: > How do I compile my prg of two libs and an executable if one of the libs > calls functions from the other one? > Simplified case: > > a.c: > ... > int foo_a(int x) > { > return x+1; > } > ... > > b.c: > ... > extern foo_a(int); > ... > int foo_b(int y) > { > return foo_a(y-1); > } > ... > > main.c: > ... > extern foo_b(int); > ... > cout< ... > > What I tried: > gcc -c a.c > ar cq liba.a a.o > ranlib liba.a > gcc -c b.c > ar cq libb.a b.o > ranlib libb.a > gcc -o main main.c -L. -la -lb > > The last command gave an 'undefined' with foo_a > What did I do wrong? > You ordered you libs incorrectly. Since b calls functions in a then you need to `gcc -o main main.c -L. -lb -la'. ===== --- Earnie Boyd: __Cygwin: POSIX on Windows__ Cygwin Newbies: __Minimalist GNU for Windows__ Mingw32 List: Mingw Home: __________________________________________________ Do You Yahoo!? Send instant messages & get email alerts with Yahoo! Messenger. http://im.yahoo.com/ -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com