* RE: simple linking question
@ 2004-04-21 16:16 Lev Assinovsky
0 siblings, 0 replies; 3+ messages in thread
From: Lev Assinovsky @ 2004-04-21 16:16 UTC (permalink / raw)
To: Ramin NIkaeen, Gcc-Help (E-mail)
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
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: simple linking question
@ 2004-04-21 15:50 Lev Assinovsky
0 siblings, 0 replies; 3+ messages in thread
From: Lev Assinovsky @ 2004-04-21 15:50 UTC (permalink / raw)
To: Ramin NIkaeen, gcc-help
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
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* simple linking question
@ 2004-04-21 14:59 Ramin NIkaeen
0 siblings, 0 replies; 3+ messages in thread
From: Ramin NIkaeen @ 2004-04-21 14:59 UTC (permalink / raw)
To: gcc-help
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-04-21 16:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-21 16:16 simple linking question Lev Assinovsky
-- strict thread matches above, loose matches on Subject: below --
2004-04-21 15:50 Lev Assinovsky
2004-04-21 14:59 Ramin NIkaeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).