How to eliminate multiple declaration error for a symbol present inboth libs( without modifying libs)

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

    How to eliminate multiple declaration error for a symbol present inboth libs( without modifying libs)

    Hi All,


    I have two libs (libFirst.a and libSecond.a). Both libs contains a
    common function func(). Now I want to link an application "app" with
    these two libs as

    gcc -o app libFirst.a libSecond.a app.c.

    It gives( and it should ) multiple declaration error . Is there any
    way to tell the linker which func() declaration it must select.

    NOTE: app need to be linked two both these libs.

    Thanks and regards,
    Raman Chalotra.
  • Raman

    #2
    Re: How to eliminate multiple declaration error for a symbol presentin both libs( without modifying libs)

    On Apr 7, 11:00 am, David Thompson <dave.thomps... @verizon.netwro te:
    On Mon, 24 Mar 2008 21:21:09 -0700 (PDT), Raman
    >
    <ramanchalo...@ gmail.comwrote:
    I have two libs (libFirst.a and libSecond.a). Both libs contains a
    common function func(). Now I want to link an application "app" with
    these two libs as
    >
    gcc -o app libFirst.a libSecond.a app.c.
    >
    It gives( and it should ) multiple declaration error . Is there any
    way to tell the linker which func() declaration it must select.
    >
    Small but important terminology point: multiple _definition_.
    >
    A _definition_ in C provides the actual entity (an object, commonly
    called a variable, or a function), and having more than one for the
    same external name is a problem. Although one that the C standard does
    not require an implementation to detect; you are mildly lucky that
    your implementation did.
    >
    A _declaration_ is _sometimes_ (also) a definition, but when it isn't,
    it only describes something defined elsewhere. It is definitely OK to
    have external declarations in different T.U.s for the same external
    entity, and that's the only (direct) way you can share it; it is also
    legal to have multiple (compatible) declarations for the same external
    entity in one T.U, and sometimes convenient.
    >
    That said, others have addressed the substance of your question.
    >
    - formerly david.thompson1 || achar(64) || worldnet.att.ne t
    Taken a note of my ignorance.

    Thanks,
    Raman Chalotra

    Comment

    Working...