g++ trouble linking against archive
- To: redhat-devel-list@xxxxxxxxxx
- Subject: g++ trouble linking against archive
- From: exits funnel <exitsfunnel@xxxxxxxxx>
- Date: Tue, 4 Jan 2005 20:17:50 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=JF+EA+fQnFktW1Yqm+ko3kluGObvA3H8yuGisY2IJNgZqVq/r5lxFMoEAgLH+gcBg6Nf4j4CjACivjBUQWMjPY9kpsBaIBEZR9xFh+dPMP8ZtpNlsLJf+SuekdZqCpR9MWMZbX2VE/zIqhQVqIV4dIZlmZGIstKKWnb6ckVu7lA= ;
- Reply-to: "Red Hat developer's list" <redhat-devel-list@xxxxxxxxxx>
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
[Kernel Newbies]
[Red Hat General]
[Fedora]
[Red Hat Install]
[Linux Kernel Development]
[Yosemite News]