Reputation: 6531
When linking an executable on Linux i get an 'undefined reference' error like this:
undefined reference to `symbol@SOMELIB_1.0'
I do not have a control of 'SOMELIB', but I do have the symbol symbol
in one of my own shared libraries. I'm absolutely sure that the symbol@SOMELIB_1.0 is the same (provides exactly the same functionality) that the symbol in my library, actually even the source code is almost the same.
How to force/alias the symbol@SOMELIB_1.0
to be linked from my library, not from SOMELIB_1.0
?
I was thinking about some kind of symbol versioning tricks in linker script, but I could not find any solution or even clues.
Thanks in advance.
Upvotes: 1
Views: 941
Reputation: 6531
After loooong fight (and search) I found a solution here. To summarize: I needed two symbols. In my source code I put something like this:
__asm__(".symver symbol1, symbol1@SOMELIB_1.0");
void symbol1(void)
{
.....
}
__asm__(".symver symbol2, symbol2@SOMELIB_1.0");
void symbol2(void)
{
.....
}
Then I needed a liker script mylib.map containing:
SOMELIB_1.0 {
symbol1;
symbol2;
};
To link "mylib.so" I needed to pass additional argument: -Wl,--version-script=mylib.map
Upvotes: 1