Re: multiple .a files linking issues

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

 



-----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-----

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux