help-gplusplus
[Top][All Lists]
Advanced

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

Linking with a static library.


From: Magnus Jonneryd
Subject: Linking with a static library.
Date: 21 Oct 2005 22:26:10 +0200
User-agent: KNode/0.8.2

Ok, I've been trying to link some C++ files for a while no and to no avail.
I'll try to explain what I've been trying to do and hopefully someone here
can give me some help (I've been trying to recreate the problem in a small
example but haven't been able to do even that).

1. I define a template, a collection, let's call it C.

2. I define two classes A and B.

3. I define two more classes each of them inherits from C, like so:
        class D:public C<A>
        class E:public C<B>
   
4. Finally i define yet another class (F) that has a member variable of type
   D and one of type E.

5. All of the above are compiled and the object-files are inserted in to a   
   library (libStuff.a). No trouble compiling.

6. Lastly I define a main-method, in which i instantiate an object of class 
   F, and tries to link with the library, now it starts to get odd. The
   linker says there are some undefined references in F to members in E,
   note it doesn't say anything about D. I know I'm linking with the library
   that should contain the definitions of all of E's members, remember, I
   put all of it in libStuff.a. What I have the most trouble with is that if
   I instantiate an object of class E in the main-method, all is fine!  
   Again, If I instantiate an object of class E I'm able to link the program
   and execute it with no trouble at all!

If anyone has the slightest idea on how to rectify this problem i would 
really appreciate it.

Thanks in advance.

Oh, I've been using: g++ 3.4.3

-- 
(Should insert humorous quotation here)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]