Re: g++ trouble linking against archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks that fixed it.  It's funny I don't see this
requirement documented  on the info page even after a
reread.  Oh well.  Thanks again.

-exits
--- Jonathan Bartlett <johnnyb@xxxxxxxxxx> wrote:

> Move -lfun to the end of the command line.
> 
> Jon
> ----
> Learn to program using Linux assembly language
> http://www.cafeshops.com/bartlettpublish.8640017
> 
> 
> On Tue, 4 Jan 2005, exits funnel wrote:
> 
> > Hello,
> >
> > I've got the following simple source files:
> >
> > //Begin fun1.cpp
> > #include <iostream.h>
> > void fun1( ) { cout << "Exits in fun1( )\n"; }
> > //End fun1.cpp
> >
> > //Begin fun2.cpp
> > #include <iostream.h>
> > void fun2( ) { cout << "Exits in fun2( )\n"; }
> > //End fun2.cpp
> >
> > //Begin funmain.cpp
> > #include <iostream.h>
> > void fun1( );
> > int main( )
> > {
> > cout << "about to call fun1( )\n";
> > fun1( );
> > cout << "just called fun1( )\n";
> > return 0;
> > }
> > //End funmain.cpp
> >
> > all of the source files are in the directory
> > /home/exits/moment/cpptest. I compile the two
> > functions like this:
> >
> > g++ -c fun1.cpp
> > g++ -c fun2.cpp
> >
> > I then archive the two resulting object files like
> > this:
> >
> > ar -cr libfun.a fun1.o fun2.o
> >
> > So far so good (I think) i've not got my library
> > containing the two functions. I can't seem to
> figure
> > out though how to link my main method agains the
> > archive. It seems this should work:
> >
> > g++ -o fun -L/home/exits/moment/cpptest -lfun
> > funmain.cpp
> >
> > but it doesn't instead g++ complains about an
> > undefined reference to fun1( ). If I just pop the
> .o
> > file on the command line when I compile/link main
> > everything is fine but I really need to get the
> > library stuff working. If anyone could point out
> what
> > I've done wrong, I'd really appreciate it. Thanks
> in
> > advance!
> >
> > -exits
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - You care about security. So do we.
> > http://promotions.yahoo.com/new_mail
> >
> > _______________________________________________
> > Redhat-devel-list mailing list
> > Redhat-devel-list@xxxxxxxxxx
> >
>
https://www.redhat.com/mailman/listinfo/redhat-devel-list
> >
> 
> _______________________________________________
> Redhat-devel-list mailing list
> Redhat-devel-list@xxxxxxxxxx
>
https://www.redhat.com/mailman/listinfo/redhat-devel-list
> 



		
__________________________________ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 

_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/redhat-devel-list

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux