Linking libraries with local symbols

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bernd Geiser

    Linking libraries with local symbols

    Recently I tried the following:

    I created two libraries lib1.a and lib2.a. Both contain the object a.o which
    instantiates a class from b1.o (or b2.o respectively), where b1.o and b2.o
    have the same interface (header) and thus the symbol names are identical.
    In order to be able to link lib1.a and lib2.a with main.cpp I tried to
    localize the duplicated symbols (with GNU objcopy) and partially linked a.o
    with b1.o and a.o with b2.o. This didn't work though.... somehow linking
    both libs with the main-file eliminated b2.o's symbols.
    So I tried to strip the localized symbols from the partially linked objects
    before packing them into the lib but this didn't work, too... for some
    reason objcopy complains that they are still required. What is going wrong?
    Localizing the symbols and resolving them by partial linkage should make a
    strip possible, or am I missing sth.?
    I hope I made myself clear enough. Any ideas how to get this working? b1.o
    and b2.o definitely need the same interface.

    Thanks,
    Bernd

  • Artie Gold

    #2
    Re: Linking libraries with local symbols

    Bernd Geiser wrote:[color=blue]
    > Recently I tried the following:
    >
    > I created two libraries lib1.a and lib2.a. Both contain the object a.o which
    > instantiates a class from b1.o (or b2.o respectively), where b1.o and b2.o
    > have the same interface (header) and thus the symbol names are identical.
    > In order to be able to link lib1.a and lib2.a with main.cpp I tried to
    > localize the duplicated symbols (with GNU objcopy) and partially linked a.o
    > with b1.o and a.o with b2.o. This didn't work though.... somehow linking
    > both libs with the main-file eliminated b2.o's symbols.
    > So I tried to strip the localized symbols from the partially linked objects
    > before packing them into the lib but this didn't work, too... for some
    > reason objcopy complains that they are still required. What is going wrong?
    > Localizing the symbols and resolving them by partial linkage should make a
    > strip possible, or am I missing sth.?
    > I hope I made myself clear enough. Any ideas how to get this working? b1.o
    > and b2.o definitely need the same interface.
    >[/color]

    Bernd:

    Outside of the words `object', `class' and `instantiate' absolutely
    nothing about your question is topical here, where we speak of the
    standard C++ language.

    I would recommend posting to news:gnu.gcc.he lp or
    news:comp.unix. programmer for more info; you might want to try to put
    together a simplified concrete example of what you're trying to do as
    well (I suspect there's a better way of doing what you're trying to do).

    HTH,
    --ag


    --
    Artie Gold -- Austin, Texas

    Comment

    Working...