473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

DLL address space and plugins

Hi,

first of all: sorry if this is not a pure C++ question, it is somewhat
OS-specific but I think it fits here best.

I have a base system with capabilities for loading plugings. Plugins
comply to a given interface and can be loaded using LoadLibrary/
dlopen. To access the plugin-object itself I use a function in every
plugin that has a predefined name using:

extern "C" __declspec(dllexport) ModuleInterface* createModule
(unsigned long id)
{
return new SpecialPlugin ();
}

This way I call GetProcAddress/dlsym to get the function pointer and
execute it to get the plugin-object in my base system.

This all works fine but I have two problems:

1. the plugin-object is created in the address-space of the DLL and
thus it can not natively use the objects (singletons) in the base
system
2. some functionality that the plugins use is in the base system.
Naturally I get linker errors if I do not compile this functionality
into each and every plugin _and_ the base system. (some of this
functionality is made up of singletons which then (see problem 1) get
instanceiated in each plugin, too)

Any suggestions on how to solve the problems or change the design to
something better are welcome!

Thanks,
Chris

Jun 11 '07 #1
7 2073
Chris wrote:
....
This way I call GetProcAddress/dlsym to get the function pointer and
execute it to get the plugin-object in my base system.
Or, you can use a factory registry pattern thing like the one in Austria
C++. If you use this methodology, you don't need to worry about the
dlsym call.
>
This all works fine but I have two problems:

1. the plugin-object is created in the address-space of the DLL and
thus it can not natively use the objects (singletons) in the base
system
You can export the appropriate singletons.
2. some functionality that the plugins use is in the base system.
Naturally I get linker errors if I do not compile this functionality
into each and every plugin _and_ the base system. (some of this
functionality is made up of singletons which then (see problem 1) get
instanceiated in each plugin, too)
You can export the appropriate symbols from your "base" system.
>
Any suggestions on how to solve the problems or change the design to
something better are welcome!
I think you can solve this problem with platform specific stuff.
Austria C++ does create a DLL that does export a number of symbols and
uses a few macros to help with that.
Jun 11 '07 #2

"Chris" wrote:
... DLL ... plugins ... LoadLibrary ... GetProcAddress ...
Those are not C++ concepts. This group is for discussing
the C++ language, and it's usage. Those sound like Microsoft
things. Ask your question in a Microsoft Windows group, such as
one of these:

comp.os.ms-windows.programmer.win32
microsoft.public.win32.programmer

(Or a group that specializes in whichever API you're using,
such as microsoft.public.dotnet.* for dotnet, etc.)

--
Cheers,
Robbie Hatley
lonewolf aatt well dott com
triple-dubya dott tustinfreezone dott org
Jun 11 '07 #3
Robbie Hatley wrote:
"Chris" wrote:
>... DLL ... plugins ... LoadLibrary ... GetProcAddress ...

Those are not C++ concepts.
C++ does introduce a unique set of issues because of name mangling and
it's important to highlight C++ specific ways of dealing with them.

The OP does have other platform specific issues thought which are best
answered as you suggested.
Jun 11 '07 #4
Gianni Mariani wrote:
Robbie Hatley wrote:
>"Chris" wrote:
>>... DLL ... plugins ... LoadLibrary ... GetProcAddress ...

Those are not C++ concepts.

C++ does introduce a unique set of issues because of name mangling and
it's important to highlight C++ specific ways of dealing with them.
The problem with answering those questions here is that the issues you've
pointed out only exist with development done using different complilers,
which is not really covered by the Standard (at least yet). The current
state of affairs is that the compatibility exists only with the source
code, and is not guaranteed at the binary level.

Of course, just mentioning those issues and where they come from may be
viewed as within ?++ realm, and therefore on topic here...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 11 '07 #5
Of course, just mentioning those issues and where they come from may be
viewed as within ?++ realm, and therefore on topic here...
Hi,

to make sure people are not confused: my question is not platform
specific. Nearly any platform can load libraries, invoke function
calls on those, etc. Let it be Windows with LoadLibrary or Linux with
dlopen, I don't care. My question is more a design problem I encounter
on how to design a plugin system.

Generally: I have a base-system and plugins. The base-system loads
plugings. The plugins need some functionality that lies in the base-
system. Can it be done this way? Any cleaner ideas?
How is this done in other projects that allow addons/plugins?
Obviously the addons in Mozilla Thunderbird access the base-system,
too. So there is a circluar access.

By the way, I found a document on open-std.org that describes ideas
about a plugin system in the C++ language coming from the "Modules &
Libraries" subgroup which works in the "C++ Modules" working group.

Regards,
Chris

Jun 12 '07 #6
Chris wrote:
....
By the way, I found a document on open-std.org that describes ideas
about a plugin system in the C++ language coming from the "Modules &
Libraries" subgroup which works in the "C++ Modules" working group.
What - my Austria C++ generic factory thing not good enough for ya ? :-)

The issue you do have is system specific however. It's not plugins,
it's accessing symbols from a "base system". Put the "base system" in a
DLL/DSO and link your plug-ins with the "base system" DLL. In Windows,
you need to explicitly export symbols. On *nix you don't as the default
is to not export them. However it's probably better if you opt to
explicitly export symbols on *nix in the future as well but you can
consider that an optimization.
Jun 12 '07 #7
On Jun 12, 3:35 pm, Chris <chrismc...@hotmail.comwrote:
Of course, just mentioning those issues and where they come
from may be viewed as within ?++ realm, and therefore on
topic here...
to make sure people are not confused: my question is not platform
specific. Nearly any platform can load libraries, invoke function
calls on those, etc. Let it be Windows with LoadLibrary or Linux with
dlopen, I don't care. My question is more a design problem I encounter
on how to design a plugin system.
Generally: I have a base-system and plugins. The base-system loads
plugings. The plugins need some functionality that lies in the base-
system. Can it be done this way? Any cleaner ideas?
How is this done in other projects that allow addons/plugins?
Obviously the addons in Mozilla Thunderbird access the base-system,
too. So there is a circluar access.
There are ways under Windows, and ways under Unix, but they are
completely different. You'll have to ask in the appropriate
group for each system you're interested in.
By the way, I found a document on open-std.org that describes
ideas about a plugin system in the C++ language coming from
the "Modules & Libraries" subgroup which works in the "C++
Modules" working group.
There has been on-going work on a module system in C++, which
would also support plug-ins. For the moment, I think, it is
just that: on-going work, and I don't think it will make it into
the next version of the standard. There are also people
concerned with dynamic loading in particular, and they may have
a stop-gap measure for that, which might make it into the next
standard.

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 13 '07 #8

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

Similar topics

3
by: Juha Suni | last post by:
I was faced with a difficult configuration issue a few days ago with another companys web service. In short, their web service requires the user to login on their page before their service can be...
1
by: Aurélien Géron | last post by:
Hi, I'd like to write a simple portable browser plugin for Internet Explorer, Netscape and if possible other navigators too. Is there a way to do that using Python? For now I'd like to develop...
4
by: stu_pb | last post by:
I am designing a plugin system for a window application using .NET(C# specifically). One of the requirements of the plugin system is to be able to dynamically load/unload plugins. My initial...
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
5
by: Christoph Haas | last post by:
Dear coders... I'm working on an application that is supposed to support "plugins". The idea is to use the plugins as packages like this: Plugins/ __init__.py Plugin1.py Plugin2.py...
5
by: Michael McCarthy | last post by:
I want to develop plugin support for a system.montitor module I am working on. A lot of the modules will do mostly interop stuff for an older system, but I want to use it myself as well to monitor...
0
by: Greg Conely via .NET 247 | last post by:
I am creating a application that will be using plugins. I am doing this so that when I want to let this application work with another type of dbase system, I only have to write\install one plugin,...
1
by: dscriv | last post by:
Hello, I have Netscape 8.0.4 (in Firefox mode) and Flash 8.0.24.0. I also have IE and Firefox installed. If I go to this page, which contains a Flash detection movie:...
7
by: Laurent Navarro | last post by:
Hello, I created a software some times ago, which uses some plugins to work (which I coded also). I had problems to load those plugins as they used some classes and functions which were...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.