Library collision

K

kj

Pardon the dumb question, but how does one link against two libraries
that both define functions foo (for example), having different
meanings and different prototypes?

My linker is complaining of having detected a redefinition of a
function. And, sure enough, looking at the appropriate header
files I see that both libraries define the same function, though
with different meanings and signatures. Since I've never seen this
sort of problem before, I suspect that I'm doing something wrong.

Any help would be much appreciated!

kj
 
K

Keith Thompson

kj said:
Pardon the dumb question, but how does one link against two libraries
that both define functions foo (for example), having different
meanings and different prototypes?

My linker is complaining of having detected a redefinition of a
function. And, sure enough, looking at the appropriate header
files I see that both libraries define the same function, though
with different meanings and signatures. Since I've never seen this
sort of problem before, I suspect that I'm doing something wrong.

Any help would be much appreciated!

There is no portable way to do this other than changing one of the
names (which requires recompiling the library from source).

There *might* be system-specific ways of resolving such conflicts.
Presumably you'd need to specify somehow which "foo" is visible from
where. Or you might be able to do something with the order in which
you specify object files when you invoke the linker, but that's ugly.
Try a system-specific newsgroup for your platform.
 
W

Walter Roberson

There is no portable way to do this other than changing one of the
names (which requires recompiling the library from source).

It goes further than that: there is no portable way of linking
libraries. Anything having to do with libraries is beyond the
scope of the C standard. All that is certain is that there will
be *some* mechanism which provides a way of translating
multiple source files and providing definitions for the standard
library functions -- there isn't even any certainty that there
will be a C library as such. [Sounds strange, but then again C
is a language which doesn't even promise that the standard header
files are in text format...]
 
R

Richard Tobin

Keith Thompson said:
There is no portable way to do this other than changing one of the
names (which requires recompiling the library from source).

Making libraries isn't portable between C implementations, but assuming
you have tools for handling libraries you may have one that lets you
extract the functions (or files) from the library and re-package them
without the undesired function.

-- Richard
 

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
474,169
Messages
2,570,918
Members
47,458
Latest member
Chris#

Latest Threads

Top