Linking libraries with local symbols

B

Bernd Geiser

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
 
A

Artie Gold

Bernd said:
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.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top