regarding .so files and dynamic linking

Discussion in 'C++' started by pratap, Feb 28, 2007.

  1. pratap

    pratap Guest

    Is there any way in which one can link a.so(Class implementation by
    Vendor A in a dynamic library) and b.so(Class implementation by Vendor
    A in a dynamic library) and use it in 1.cpp
    where 1.cpp
    would contain
    int main()
    {
    A a,Bb
    return 0;
    }

    The idea here is to instantiate class object a from class A which is
    defined in a.so and class object b from class B which is defined in
    b.so.
     
    pratap, Feb 28, 2007
    #1
    1. Advertising

  2. On Feb 28, 1:12 pm, "pratap" <> wrote:
    > Is there any way in which one can link a.so(Class implementation by
    > Vendor A in a dynamic library) and b.so(Class implementation by Vendor
    > A in a dynamic library) and use it in 1.cpp
    > where 1.cpp
    > would contain
    > int main()
    > {
    > A a,Bb
    > return 0;
    >
    > }
    >
    > The idea here is to instantiate class object a from class A which is
    > defined in a.so and class object b from class B which is defined in
    > b.so.


    This is off-topic here since it's vendor-dependent, but usually you
    have to include some files, like a.h and b.h, so 1.cpp would look
    something like:

    #include "a.h" // or perhaps <a.h>
    #include "b.h"

    int main()
    {
    A a;
    B b;
    }

    The rest is then up to the linker.

    --
    Erik Wikström
     
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, Feb 28, 2007
    #2
    1. Advertising

  3. pratap

    pratap Guest

    On Feb 28, 5:29 pm, "Erik Wikström" <>
    wrote:
    > On Feb 28, 1:12 pm, "pratap" <> wrote:
    >
    > > Is there any way in which one can link a.so(Class implementation by
    > > Vendor A in a dynamic library) and b.so(Class implementation by Vendor
    > > A in a dynamic library) and use it in 1.cpp
    > > where 1.cpp
    > > would contain
    > > int main()
    > > {
    > > A a,Bb
    > > return 0;

    >
    > > }

    >
    > > The idea here is to instantiate class object a from class A which is
    > > defined in a.so and class object b from class B which is defined in
    > > b.so.

    >
    > This is off-topic here since it's vendor-dependent, but usually you
    > have to include some files, like a.h and b.h, so 1.cpp would look
    > something like:
    >
    > #include "a.h" // or perhaps <a.h>
    > #include "b.h"
    >
    > int main()
    > {
    > A a;
    > B b;
    >
    > }
    >
    > The rest is then up to the linker.
    >
    > --
    > Erik Wikström



    Does not work
    Have tried that
     
    pratap, Feb 28, 2007
    #3
  4. pratap

    Lionel B Guest

    Re: [OT] regarding .so files and dynamic linking

    On Wed, 28 Feb 2007 04:45:10 -0800, pratap wrote:

    > On Feb 28, 5:29 pm, "Erik Wikström" <>
    > wrote:
    >> On Feb 28, 1:12 pm, "pratap" <> wrote:
    >>
    >> > Is there any way in which one can link a.so(Class implementation by
    >> > Vendor A in a dynamic library) and b.so(Class implementation by Vendor
    >> > A in a dynamic library) and use it in 1.cpp
    >> > where 1.cpp
    >> > would contain
    >> > int main()
    >> > {
    >> > A a,Bb
    >> > return 0;

    >>
    >> > }

    >>
    >> > The idea here is to instantiate class object a from class A which is
    >> > defined in a.so and class object b from class B which is defined in
    >> > b.so.

    >>
    >> This is off-topic here since it's vendor-dependent, but usually you
    >> have to include some files, like a.h and b.h, so 1.cpp would look
    >> something like:
    >>
    >> #include "a.h" // or perhaps <a.h>
    >> #include "b.h"
    >>
    >> int main()
    >> {
    >> A a;
    >> B b;
    >>
    >> }
    >>
    >> The rest is then up to the linker.
    >>
    >> --
    >> *********

    ^ ^ ^ ^ ^
    Don't quote signatures.

    > Does not work


    What happens? Doesn't compile? doesn't link? compiles and links but
    doesn't run correctly? Makes computer explode?

    > Have tried that


    Tried what??? What did you do to compile/link/run?

    How can we help you if you don't give us any information?

    See: http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8

    --
    Lionel B
     
    Lionel B, Feb 28, 2007
    #4
  5. pratap

    pratap Guest

    On Feb 28, 7:04 pm, Lionel B <> wrote:
    > On Wed, 28 Feb 2007 04:45:10 -0800, pratap wrote:
    > > On Feb 28, 5:29 pm, "Erik Wikström" <>
    > > wrote:
    > >> On Feb 28, 1:12 pm, "pratap" <> wrote:

    >
    > >> > Is there any way in which one can link a.so(Class implementation by
    > >> > Vendor A in a dynamic library) and b.so(Class implementation by Vendor
    > >> > A in a dynamic library) and use it in 1.cpp
    > >> > where 1.cpp
    > >> > would contain
    > >> > int main()
    > >> > {
    > >> > A a,Bb
    > >> > return 0;

    >
    > >> > }

    >
    > >> > The idea here is to instantiate class object a from class A which is
    > >> > defined in a.so and class object b from class B which is defined in
    > >> > b.so.

    >
    > >> This is off-topic here since it's vendor-dependent, but usually you
    > >> have to include some files, like a.h and b.h, so 1.cpp would look
    > >> something like:

    >
    > >> #include "a.h" // or perhaps <a.h>
    > >> #include "b.h"

    >
    > >> int main()
    > >> {
    > >> A a;
    > >> B b;

    >
    > >> }

    >
    > >> The rest is then up to the linker.

    >
    > >> --
    > >> *********

    >
    > ^ ^ ^ ^ ^
    > Don't quote signatures.
    >
    > > Does not work

    >
    > What happens? Doesn't compile? doesn't link? compiles and links but
    > doesn't run correctly? Makes computer explode?
    >
    > > Have tried that

    >
    > Tried what??? What did you do to compile/link/run?
    >
    > How can we help you if you don't give us any information?
    >
    > See:http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8
    >
    > --
    > Lionel B



    SUCCESS!!!

    tried

    gcc -rdynamic -o 1 1.cpp -L/path of so files/ -la -lb
    where -la and -lb are liba.so and libb.so
    and it worked.
    was using the wrong flags while making.
     
    pratap, Mar 2, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kirok
    Replies:
    2
    Views:
    363
    Kirok
    Nov 10, 2005
  2. Motta

    IFAME and dynamic linking

    Motta, May 21, 2004, in forum: HTML
    Replies:
    2
    Views:
    691
    Richard
    May 22, 2004
  3. Lior Sapir
    Replies:
    1
    Views:
    606
    Victor Bazarov
    Mar 31, 2005
  4. Replies:
    1
    Views:
    328
    dorayme
    Jan 24, 2007
  5. Rajeshwaran

    Static and Dynamic Linking

    Rajeshwaran, Apr 11, 2007, in forum: C Programming
    Replies:
    1
    Views:
    314
    Chris Dollin
    Apr 11, 2007
Loading...

Share This Page