simple linking question
Lev Assinovsky
LAssinovsky@algorithm.aelita.com
Wed Apr 21 16:16:00 GMT 2004
You are welcome!
----
Lev Assinovsky
Aelita Software Corporation
(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 8:10 PM
> To: Lev Assinovsky
> Subject: RE: simple linking question
>
>
>
> Hi Lev,
>
> Yes it works. Thanks for your help.
>
> ramin
> -----Original Message-----
> From: Lev Assinovsky [mailto:LAssinovsky@algorithm.aelita.com]
> Sent: Wednesday, April 21, 2004 11:49 AM
> To: Ramin NIkaeen; gcc-help@gcc.gnu.org
> Subject: RE: simple linking question
>
>
> I would advise to put -ljingjing after main.cpp:
> g++ -o test.exe -L/usr/lib -L/home/test test.cpp -ljingjing
>
>
> ----
> Lev Assinovsky
> Aelita Software Corporation
> (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
> >
> >
> >
> > Friends,
> >
> > I am having linking problems with user-generated libraries on
> > my Redhat 7.2
> > using gcc-3.3.
> >
> > To demonstrate the problem, I created the following simple example:
> >
> > /*
> > --------------------------------------------------------------
> > --------------------------------------------------------------
> > FILE: /home/test/jingjing.hpp
> > --------------------------------------------------------------
> > -------------------------------------------------------------- */
> >
> > #ifndef JINGJING_H
> > #define JINGJING_H
> >
> > void jingjing();
> >
> > #endif
> >
> > /*
> > --------------------------------------------------------------
> > --------------------------------------------------------------
> > FILE: /home/test/jingjing.cpp
> > --------------------------------------------------------------
> > -------------------------------------------------------------- */
> > #include "jingjing.hpp"
> > #include <stdio.h>
> >
> > void jingjing()
> > {
> > fprintf(stderr, "jingjing invoked!\n");
> > }
> >
> > /*
> > --------------------------------------------------------------
> > --------------------------------------------------------------
> > FILE: test.cpp
> > --------------------------------------------------------------
> > -------------------------------------------------------------- */
> > #include "jingjing.hpp"
> >
> > int main()
> > {
> >
> > jingjing();
> >
> > return 0;
> > }
> >
> > --------------------------------------------------------------
> > -----------------------------------------------------------------
> > 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
> > -ljingjing test.cpp
> >
> > At the linking stage, when I execute the last command shown
> > 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
> > --------------------------------------------------------------
> > -----------------------------------------------------------------
> >
> > when I try
> > /home/test>g++ jingjing.o test.cpp
> > it generates the executable properly.
> >
> > but when I try
> > /home/test>g++ libjingjing.a test.cpp
> > I get the same error.
> >
> > Can someone tell me what is wrong?!
> >
> >
> > thanks so much
> >
> > ramin
> >
> >
> >
> >
>
More information about the Gcc-help
mailing list