Thread: how to bypass multiple function deffinitions

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    222

    how to bypass multiple function deffinitions

    Hi,

    here is the situation. I am using a library X that has functions x,y,z plus some others. also i am using a library Y that has those same functions (x,y,z) plus some others. (so both libraries have certain objects that are shared). libraries are designed to do different things and i need them both . However when i load them both i get

    sem.c.text+0x2c10): multiple definition of `upper'
    ...

    errors.


    libraries are big and rewriting is not an option for me. Question: how do i bypass this problem??

    b

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    I'd query why you're using both libraries in the first place, if they duplicate related functions. That makes me think "design problem of your program".

    If your libraries are linked in (i.e. not dynamically loaded at run time) then the common approach is to obtain the source code and rename the offending functions and objects to prevent clashes.

    An alternative is to write a wrapper library for one (both if needed) of the offending libraries that acts as an intermediary between your program and the offending library. It exports a set of functions (suitably renamed) for use by your program and, internally, dynamically loads and uses the offending library. This means your program does not directly use (or even have visibility of) the offending library at all - it always goes via the wrapper. That's tedious (particularly if the library being wrapped exports a lot of functions your program needs), but you are working around a problem of poor design, after all.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ternary operation as confusing as quadruple bypass
    By forestprimeval in forum C Programming
    Replies: 3
    Last Post: 08-23-2012, 11:55 PM
  2. Bypass having to hit Enter after getch
    By omGeeK in forum C Programming
    Replies: 2
    Last Post: 03-12-2011, 11:37 PM
  3. TCP/IP stack bypass
    By wyliek in forum Linux Programming
    Replies: 4
    Last Post: 08-19-2009, 02:14 PM
  4. Can OS bypass the BIOS?
    By siavoshkc in forum Tech Board
    Replies: 31
    Last Post: 08-09-2006, 10:53 AM