472,354 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Shared libraries / C++

I have a program that is going to have plugins used for various
capabilities. The main program creates a class (AppCore) which handles
everything. This class contains another class (PluginController) that
handles loading the shared objects via the dl* functions. When I
create the plugins, I link them using -shared.

The plugins themselves are derived from a class (Plugin)... inside of
the Plugin class there is a variable to hold a pointer back to the
AppCore object. This is so the plugins can call various functions from
AppCore object created at start up.

Should I have to link in the AppCore.o the plugins when I'm creating
them? It seems like it wont work unless I do that.. I'm not sure I
understand why I need to link those in.. shouldn't the main program
export those symbols?

Jul 23 '05 #1
4 1462
jo***********@gmail.com wrote:
I have a program that is going to have plugins used for various
capabilities. The main program creates a class (AppCore) which handles
everything. This class contains another class (PluginController) that
handles loading the shared objects via the dl* functions. When I
create the plugins, I link them using -shared.

The plugins themselves are derived from a class (Plugin)... inside of
the Plugin class there is a variable to hold a pointer back to the
AppCore object. This is so the plugins can call various functions from
AppCore object created at start up. Should I have to link in the AppCore.o
the plugins when I'm creating them? It seems like it wont work unless I
do that.. I'm not sure I understand why I need to link those in..
shouldn't the main program export those symbols?


No. At least under Linux, the plug-in doesn't have access to any symbols of
the main program. The usual solution to that is to write a shared library
that contains everything that both the main program and the plug-in need,
and then link them both to that library.

Jul 23 '05 #2
No, you don't need to link plugin DLL (SO) files with AppCode.
Moreone, you should not do that :)

Jul 23 '05 #3

jo***********@gmail.com wrote:
I have a program that is going to have plugins used for various
capabilities. The main program creates a class (AppCore) which handles everything. This class contains another class (PluginController) that handles loading the shared objects via the dl* functions. When I
create the plugins, I link them using -shared.

The plugins themselves are derived from a class (Plugin)... inside of
the Plugin class there is a variable to hold a pointer back to the
AppCore object. This is so the plugins can call various functions from AppCore object created at start up.

Should I have to link in the AppCore.o the plugins when I'm creating
them? It seems like it wont work unless I do that.. I'm not sure I
understand why I need to link those in.. shouldn't the main program
export those symbols?


The problem with this is that it introduces cyclic dependencies (bad
thing). i.e., AppCore depends on PluginController, and
PluginController depends on AppCore (to pass the pointer to the plugins
when loaded). You will have something like this:

,---------. ,------------------.
| |------->| |
| AppCore | | PluginController |
| |<-------| |
`---------' `------------------'

One solution is to have a pure virtual interface (e.g., AppInterface),
that provides all the methods that plugins would need to call in the
applications. Have AppCore implement this interface and just pass the
pointer to AppInterface. That way, your dependency diagram looks like
this:

,---------. ,--------------. ,------------------.
| AppCore |---->| AppInterface |<----| PluginController |
`---------' `--------------' `------------------'

Your linker will thank you for it :)

Hope this helps,
-shez-

Jul 23 '05 #4
Thanks a ton! That's exactly what I was looking for. I implemented it
using an API class that is included by the core, and the plugins.
Cyclic dependencies are now gone, and it links the way I want it.

Thank you very much :o)

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled...
0
by: Frieder Loercher | last post by:
Hello, I am developping a (lammpi) parallel Application where any of the processes uses the Python script language. It works fine on Compaq Alpha and SUN Solaris5.9 On AIX5.1, it doesn't...
3
by: Rickard Lind | last post by:
Is there any way to build the python executable statically and still be able to load modules built as shared libraries? I'm trying to run python scripts on a stripped down FreeBSD (4.9) machine...
1
by: rinku24 | last post by:
We have two C++ libraries (Unix Shared objects) with the same class name and no namespace. Is there any way to load both the libraries and selectivly create the instance of the class from...
1
by: RHNewBie | last post by:
Hello, I have an executable which uses two shared libraries(A and Z). I do not have the source code for the executable. However I can tell the executable to load the shared libraries and invoke...
5
by: David T. Ashley | last post by:
I've occasionally had trouble compiling and linking programs that use shared libraries. That never made a lot of sense to me, because I thought the operating system went hunting for the symbols...
2
by: Tobias Bergmann | last post by:
Hi, I work on a big project that consists of many small linux C++ CGI binaries. This actually works fine but our problem is that we use many ..so libraries and we need to compile it separately...
3
by: Bala | last post by:
Hello, I am trying to create a shared library on solaris. The inputs to this library is a source file and then 2 static libraries. I need to call code within the shared library in another...
3
by: S S | last post by:
Hi Are there some known issues using STL with shared library. Recently I got some crash for which the reason I dont see any, and searching on goolge shown some such issues with shared library. ...
4
by: stuntgoat | last post by:
Hi, I want to start using Python 2.6 and 3000. I have several questions. What, in your experiences, is a functionally elegant solution to installing 2.6 and 3 from source without breaking...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.