From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23296 invoked by alias); 21 Apr 2004 15:50:36 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 23167 invoked from network); 21 Apr 2004 15:50:34 -0000 Received: from unknown (HELO gate.algorithm.aelita.com) (212.176.18.2) by sources.redhat.com with SMTP; 21 Apr 2004 15:50:34 -0000 Received: from bagman.edm.com ([10.30.32.14]) by gate.algorithm.aelita.com (Post.Office MTA v3.5.3 release 223 ID# 0-12345L500S10000V35) with ESMTP id com for ; Wed, 21 Apr 2004 19:50:32 +0400 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: simple linking question Date: Wed, 21 Apr 2004 15:50:00 -0000 Message-ID: <3F6F4712B759A34ABD453A8B39C10D62022B1C1A@bagman.edm.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: From: "Lev Assinovsky" To: "Ramin NIkaeen" , X-SW-Source: 2004-04/txt/msg00274.txt.bz2 I would advise to put -ljingjing after main.cpp: g++ -o test.exe -L/usr/lib -L/home/test test.cpp -ljingjing =20=20=20=20=20 ---- Lev Assinovsky Aelita Software Corporation=20 (now is a part of Quest Software) O&S InTrust Framework Division, Team Leader ICQ# 165072909 > -----Original Message----- > From: Ramin NIkaeen [mailto:Rnikaeen@goldline.net] > Sent: Wednesday, April 21, 2004 7:00 PM > To: gcc-help@gcc.gnu.org > Subject: simple linking question >=20 >=20 >=20 > Friends, >=20 > I am having linking problems with user-generated libraries on=20 > my Redhat 7.2 > using gcc-3.3. >=20 > To demonstrate the problem, I created the following simple example: >=20 > /*=20 > -------------------------------------------------------------- > -------------------------------------------------------------- > FILE: /home/test/jingjing.hpp > -------------------------------------------------------------- > -------------------------------------------------------------- */ >=20 > #ifndef JINGJING_H > #define JINGJING_H >=20 > void jingjing(); >=20 > #endif >=20 > /*=20 > -------------------------------------------------------------- > -------------------------------------------------------------- > FILE: /home/test/jingjing.cpp > -------------------------------------------------------------- > -------------------------------------------------------------- */ > #include "jingjing.hpp" > #include >=20 > void jingjing() > { > fprintf(stderr, "jingjing invoked!\n"); > } >=20 > /*=20 > -------------------------------------------------------------- > -------------------------------------------------------------- > FILE: test.cpp > -------------------------------------------------------------- > -------------------------------------------------------------- */ > #include "jingjing.hpp" >=20 > int main() > { >=20 > jingjing(); >=20 > return 0; > } >=20 > -------------------------------------------------------------- > ----------------------------------------------------------------- > compilation and linking > -------------------------------------------------------------- > ----------------------------------------------------------------- > /home/test>g++ -g -O2 -c jingjing.cpp -o jingjing.o > /home/test>ar cru libjingjing.a jingjing.o > /home/test>ranlib libjingjing.a > /home/test>chmod 755 *.o *.a > /home/test>g++ -o test.exe -L/usr/lib -L/home/test=20=20=20 > -ljingjing test.cpp >=20 > At the linking stage, when I execute the last command shown=20 > on the last line (g++ -o test.exe ....), > I get the following error: > -------------------------------------------------------------- > ----------------------------------------------------------------- > /tmp/ccuw3cNo.o: In function `main': > /tmp/ccuw3cNo.o(.text+0x11): undefined reference to `jingjing()' > collect2: ld returned 1 exit status > -------------------------------------------------------------- > ----------------------------------------------------------------- >=20 > when I try=20 > /home/test>g++ jingjing.o test.cpp > it generates the executable properly. >=20 > but when I try=20=20 > /home/test>g++ libjingjing.a test.cpp > I get the same error. >=20 > Can someone tell me what is wrong?! >=20 >=20 > thanks so much >=20 > ramin >=20 >=20 >=20 >=20