regarding .so files and dynamic linking

P

pratap

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?=

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.
 
P

pratap

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.


Does not work
Have tried that
 
P

pratap

^ ^ ^ ^ ^
Don't quote signatures.


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


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


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.
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top