This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: multiple .a files linking issues


Thaks Harald! It worked after I switched the order

But this is even more tedious, Now I have to remember the order of my
libraries. I wonder what would happen if I have two libraries that calls
each other(I know, bad practice, but it will happen sooner or later as your
library grows)? Whichever one goes first the other one will get screwed up?


Harald Servat-3 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> Hello Robin,
> 
>   have you tried swapping the order of the libraries like:
> 
>   g++ myapp.o /mylib/libB.a /mylib/libA.a -o myapp
> 
> Regards.
> 
> En/na RobinK ha escrit:
>> Apologize first if this has already been asked before.
>> 
>> Here is my issue: I have two libraries, libA and libB, in libB there is a
>> class inherit from a class in libA and calls one of A's member function.
>> so
>> like this:
>> In A.h:
>> class A{
>> public:
>>     void func1() ;
>> }
>> 
>> In A.cpp:
>> 
>> void A::func1(){
>> ...
>> }
>> 
>> In libB:
>> B.h:
>> 
>> class B : public A{
>> public:
>>     void func2() ;
>> }
>> 
>> B.cpp:
>> 
>> void B::func2(){
>>     func1() ;
>>     ...
>> }
>> 
>> I found I have trouble linking these two libraries together with my final
>> binary. If I link my binary against libA.o and libB.o everything works
>> fine,
>> but if I do something like this:
>> g++ /mylib/libA.a /mylib/libB.a myapp.o -o myapp
>> It would complain:
>> /mylib/libB.a undifined reference to func1()
>> 
>> Is this to be expected? That I am supposed to use .o file instead of .a
>> file?
>> 
>> Thanks!
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.9 (GNU/Linux)
> 
> iEYEARECAAYFAksiXj8ACgkQwMPeuqUCg9ySIQCfalxw7Ft9ZkZlnMICh7Betacm
> lpsAn2p4CJ3zPILV76//YcGAy1lBO7u1
> =2rC7
> -----END PGP SIGNATURE-----
> 
> 

-- 
View this message in context: http://old.nabble.com/multiple-.a-files-linking-issues-tp26745612p26746218.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]