Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   regarding .so files and dynamic linking (http://www.velocityreviews.com/forums/t460789-regarding-so-files-and-dynamic-linking.html)

pratap 02-28-2007 12:12 PM

regarding .so files and dynamic linking
 
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.


=?iso-8859-1?q?Erik_Wikstr=F6m?= 02-28-2007 12:29 PM

Re: regarding .so files and dynamic linking
 
On Feb 28, 1:12 pm, "pratap" <pratappa...@gmail.com> 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


pratap 02-28-2007 12:45 PM

Re: regarding .so files and dynamic linking
 
On Feb 28, 5:29 pm, "Erik Wikström" <eri...@student.chalmers.se>
wrote:
> On Feb 28, 1:12 pm, "pratap" <pratappa...@gmail.com> 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


Lionel B 02-28-2007 02:04 PM

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" <eri...@student.chalmers.se>
> wrote:
>> On Feb 28, 1:12 pm, "pratap" <pratappa...@gmail.com> 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-lit...t.html#faq-5.8

--
Lionel B

pratap 03-02-2007 06:59 AM

Re: regarding .so files and dynamic linking
 
On Feb 28, 7:04 pm, Lionel B <m...@privacy.net> wrote:
> On Wed, 28 Feb 2007 04:45:10 -0800, pratap wrote:
> > On Feb 28, 5:29 pm, "Erik Wikström" <eri...@student.chalmers.se>
> > wrote:
> >> On Feb 28, 1:12 pm, "pratap" <pratappa...@gmail.com> 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-lit...t.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.



All times are GMT. The time now is 04:12 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.