Info regarding multiply linking single static lib

This is a discussion on Info regarding multiply linking single static lib within the Windows Programming forums, part of the Platform Specific Boards category; So I haven't done any programming in a while, and to ease my way back into a rather massive project ...

  1. #1
    Peace
    Join Date
    Aug 2001
    Posts
    1,510

    Info regarding multiply linking single static lib

    So I haven't done any programming in a while, and to ease my way back into a rather massive project I decided to lump one aspect of the menial functions (which includes about 10 different classes and data etc) into a static-link lib. But a thought just occured to me I can't find a quick answer to, and I figured someone here would probably know.

    My app already uses a SLL called Common.LIB full of extremely low level tools (data, error, memory handling etc). Many of those tools use templates, and what I'm wondering is, if foo.LIB links Common.LIB and Project bar links both fu AND Common; Will MSVC 6.0 be smart enough to use code already generated from the templated Common classes which will be found in foo.LIB or will it generate a whole second set of identical code, thus bloating the app?

    To further illustrate my point (as that may have been a little confusing):
    Code:
    //Project Foo uses a templated Common.LIB class thus
    CommonData<int> SomeStuff;
    CommonData<char *> SomeOtherStuff;
    
    //and so now Foo.LIB will contain code for an int and a char * version of the CommonData class...
    
    //Project Bar links to Foo.LIB and Common.LIB, then desires this:
    CommonData<int> DataForBar;
    So, will the final compiled executable contain 2 identical code segments for an int verson of CommonData? What will actually happen?
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    No. If it does, the compiler is plain stupid!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 12:29 PM
  2. Linking error with static template class members
    By cunnus88 in forum C++ Programming
    Replies: 6
    Last Post: 04-02-2009, 01:31 PM
  3. Problem with Free.
    By chakra in forum C Programming
    Replies: 9
    Last Post: 12-15-2008, 11:20 AM
  4. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  5. Help doing an e-mail program in c...
    By Tyler_Durden in forum C Programming
    Replies: 88
    Last Post: 01-02-2005, 03:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21