1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

c++ libarys

Discussion in 'C++' started by TriG0rZ, Dec 5, 2008.

  1. TriG0rZ

    TriG0rZ New Member

    Joined:
    Oct 2, 2008
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    UK
    does it matter how many libarys you include within a c++ program, so you can have like as many as you want and it wont mater OR does it, does having to many libars conflict with each other??

    Thanks <3 TriG0rZ
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    As far as conflict goes no but if you include more your binary size increases
     
  3. TriG0rZ

    TriG0rZ New Member

    Joined:
    Oct 2, 2008
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    UK
    oh right awesome thanks...another question what is binary size ^_^
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Size of your executable, i.e. number of bytes the file takes up on disk and in memory.
    The executable size depends on how smart the linker is; ideally it shouldn't include any functions that aren't referenced, so you could have endless irrelevant libraries and it won't affect the resulting size, but if you have a dumb linker it will include everything anyway and every new library you add will increase the executable size.
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    In Visual Studio Linker can be manually set to Statically Link the MFC Dll or Dynamic Linking and if you choose Statically linked option you would see size of the exe grows to MB for hello world.

    Now about the conflict its not that there cannot be a conflict but there is highly unlikely that multiple Libraries ( 3rd party ) have the same function defined with the same signature can lead to problems but then I haven't come across any such things but it could be that I am just lucky enough.
     
  6. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    It does happen from time to time, I had a customer at work only a few weeks ago with exactly this problem and he was insisting it was a bug in our software and demanding we changed it. He had also posted a similar message to the help forums on the other library. The forum was less polite than I was allowed to be and he got told where to go in very few words, but I was able to persuade him with the question "ok then, what name should we give the function that is guaranteed not to clash with any other software at any time past or future", or something like that.

    Actually the problem isn't that difficult to solve, you just have two executables that run in parallel, one linking with one library and one linking with the other, and you define some kind of IPC between the two executables. One can be just a thin wrapper around one of the libraries; you don't necessarily have to split the application down the middle.
     

Share This Page