473,757 Members | 8,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shared Library Question

Hello,

i want to extend a program of mine with a plugin architecture.
I can load and use the shared libs which are implementations of a
abstract base class without any problems. But what i need is a
bi-directional interface, the plugins have to acess objects of the
main programm (pointers to them are passed at plugin initialisation) .
This works too - but only if i include the header and .cpp files of
these api objects into every plugin - and that is bloated bullshit !

is there a way to include the api .h files only and uses the
implementation code from the main-application (gcc 3.2 linux 2.4) ??
if i try to do that library loading fails with unresolved symbols
.....

Thanx C.S.
Jul 19 '05 #1
4 4209
"listigerBi ber" <c.********@urz .uni-heidelberg.de> wrote...
i want to extend a program of mine with a plugin architecture.
I can load and use the shared libs which are implementations of a
abstract base class without any problems. But what i need is a
bi-directional interface, the plugins have to acess objects of the
main programm (pointers to them are passed at plugin initialisation) .
This works too - but only if i include the header and .cpp files of
these api objects into every plugin - and that is bloated bullshit !

is there a way to include the api .h files only and uses the
implementation code from the main-application (gcc 3.2 linux 2.4) ??
if i try to do that library loading fails with unresolved symbols
....


What you need is to provide an SDK to the writers of plug-ins. You
have determined what classes plug-ins need, now you have to expose
those classes. The most convenient way is to create "pure abstract"
interfaces. The real objects that will do the work you will create
on demand in some kind of factory function. The plug-ins will call
your factory or will receive the pointers to base classes some other
way, then will call the methods of those base classes, which will
resolve in calls to the implementations through polymorphism.

So, you basically on the right track. Simply extract the interface
the plug-ins will use into the base class, declare those functions
virtual and pure. Make your classes derive from those interfaces,
create the instances of your classes and pass the addresses as base
class pointers to plug-ins.

Victor
Jul 19 '05 #2
Hi listigerBiber, all,
One way to implement a C interface which I have used quite a lot is to make each plugin have only one function. The function returns a pointer to a C
struct which has nothing but function pointers.


id's QuakeII engine (GPL) uses a very similar method. The loading
module and loaded module exchange references through one function call.

struct import
{
//lots of pointers to funcs in other module
} Ii;

struct export
{
//lots more pointers to funcs in current module
}Ie;

//init pointers in Ie to local functions you want to access in other module

__declspec(dlle xport) import GetAPI(export Ie); //defined in other
module--platform specific interface
Ii = GetAPI(Ie); //this func saves off the Ie info and then inits the Ii
pointers to its local funcs to be accessed in the calling module
I have a different method for doing the same thing. I made a global
data tree where each node looks like:

struct Glob
{
char szName[MAX_STRING];
DWORD dwFlags; //valid fields and requests
char szValue[MAX_STRING];
int iValue;
float fValue;
void* pVoid;
PGLOB pParentGlob;
PGLOB pLeftGlob;
PGLOB pRightGlob;
};

Then, pointers to my equivalent of the above import/export structs would
be placed in Glob::pVoid for all to access.

HTH
--

Best wishes,
Allen

No SPAM in my email !!


Jul 19 '05 #3
"Allen" <al************ @att.SPAM.net> wrote in message
news:WM******** *************@b gtnsc04-news.ops.worldn et.att.net...
Hi listigerBiber, all,
One way to implement a C interface which I have used quite a lot is to make
each plugin have only one function. The function returns a pointer to a C struct which has nothing but function pointers.


id's QuakeII engine (GPL) uses a very similar method. The loading
module and loaded module exchange references through one function call.

struct import
{
//lots of pointers to funcs in other module
} Ii;

struct export
{
//lots more pointers to funcs in current module
}Ie;

//init pointers in Ie to local functions you want to access in other

module
__declspec(dlle xport) import GetAPI(export Ie); //defined in other
module--platform specific interface
Ii = GetAPI(Ie); //this func saves off the Ie info and then inits the Ii pointers to its local funcs to be accessed in the calling module
I have a different method for doing the same thing. I made a global
data tree where each node looks like:

struct Glob
{
char szName[MAX_STRING];
DWORD dwFlags; //valid fields and requests
char szValue[MAX_STRING];
int iValue;
float fValue;
void* pVoid;
PGLOB pParentGlob;
PGLOB pLeftGlob;
PGLOB pRightGlob;
};

Then, pointers to my equivalent of the above import/export structs would be placed in Glob::pVoid for all to access.

HTH
--

Best wishes,
Allen

No SPAM in my email !!

Funny you should mention QuakeII. I'm the author of the QuakeII mods WoD7
and WoD8. :) But as you say, it was iD software that wrote the stuff you're
talking about.

Guess in this context I'll use my real sig, including my QuakeII clan name
LOL

--
Cycho{HHR}
http://home.rochester.rr.com/cyhome/
Jul 19 '05 #4
Thank you very much !
your hint with the abstract base class for the pluginfactory worked
....
of course the pluginfactory or application api must have a pure
virtual base class !!

"Victor Bazarov" <v.********@att Abi.com> wrote in message news:<9l******* ************@rw crnsc51.ops.asp .att.net>...
"listigerBi ber" <c.********@urz .uni-heidelberg.de> wrote...
i want to extend a program of mine with a plugin architecture.
I can load and use the shared libs which are implementations of a
abstract base class without any problems. But what i need is a
bi-directional interface, the plugins have to acess objects of the
main programm (pointers to them are passed at plugin initialisation) .
This works too - but only if i include the header and .cpp files of
these api objects into every plugin - and that is bloated bullshit !

is there a way to include the api .h files only and uses the
implementation code from the main-application (gcc 3.2 linux 2.4) ??
if i try to do that library loading fails with unresolved symbols
....


What you need is to provide an SDK to the writers of plug-ins. You
have determined what classes plug-ins need, now you have to expose
those classes. The most convenient way is to create "pure abstract"
interfaces. The real objects that will do the work you will create
on demand in some kind of factory function. The plug-ins will call
your factory or will receive the pointers to base classes some other
way, then will call the methods of those base classes, which will
resolve in calls to the implementations through polymorphism.

So, you basically on the right track. Simply extract the interface
the plug-ins will use into the base class, declare those functions
virtual and pure. Make your classes derive from those interfaces,
create the instances of your classes and pass the addresses as base
class pointers to plug-ins.

Victor

Jul 19 '05 #5

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

Similar topics

0
2270
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 with the Sun Compiler version 8. My problem is that EVERYTHING builds great EXCEPT that the 6b distribution of JPEG will NOT build a shared object, thus gd cannot include support for JPEG, thus php loses that functionality.
1
4421
by: AH | last post by:
I have two functions in my shared library which are declared as follows: void setName(const std::string& str); std::vector<std::string> getInfo(); Since the code is compiled and in shared library. Every thing is great if the customer of my shared library is using the same compiler version (and same STL version). I am wondering if the customer changes their compiler version (or STL version) which may have same interface
9
4183
by: Invalidlastname | last post by:
Hi, We developed some assemblies which use EnterpriseServices queued components. In order to use EnterpriseServices, these assemblies need to be installed into GAC. I used the pre-build and post-build events to automate GAC installation processes and the asp.net application has "copy to local" set to false for the references of these shared assemblies. However, every time we made the changes to the shared assemblies, we had to restart...
6
14855
by: Jeff | last post by:
Hi - I understand how to create a directory folder, but how can I programatically create a _shared_ directory folder and set its permissions?? (I'm using VB.NET.) Thanks for your help. - Jeff
11
2539
by: Matt Kowalczyk | last post by:
I hope I am posting this to the right newsgroup. I tried submitting this to the autoconf@gnu.org mailing list, but I see no activity. If this is the wrong newsgroup, I would appriciate a reference to a different source. My question was: One of my source files uses the library: #include <openssl/md5.h>
0
1545
by: zztlhb | last post by:
Hi, I currently hit an issue that I would like to use a function statically linked to a shared library but my program use the same function from another shared library. Here is what I do: 1. I have toto.cxx that has one function called: toto() {cout << "static toto" << endl;} 2. I create an archive say toto.a has the toto.o 3. I have toto1.cxx that has one functin called toto() {cout cout <<"shared toto"<<endl;} 4. I create a shared...
3
2524
by: abhi147 | last post by:
Hi , I am trying to create a shared library and trying to load it usinf dlopen() function . My code and steps to create and load the *.so is : /*** test.c ***/ #include <stdio.h> void test() {
5
475
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 and libraries at runtime (and not before). Questions: a)How do the development tools know that a given symbol (a function entry point, for example) is located in a shared library and won't be linked in statically?
4
3072
by: gopan | last post by:
I want to call the 'stat' system call dynamically. In other words, I want to use the dlopen to dynamically load a shared library and bind to the stat function using dlsym. I want to be able to do this on Linux (Ubuntu) and Mac OS X. My questions are: 0) Given a function name, how can I fiund out if it is available in a shared library (.so) or only in a static library(.a)? 1) Given a function name, how can I find which shared library...
11
2739
by: sunil | last post by:
Hi , Am facing one problem while deploying the shared library in different boxes. I devoloped one shared library for TAM suite ( This is a IBM product for different authentication mechanisms) to customise that product for a different scenario. We deployed the TAM in different boxex and the same library file is deployed in all the machines. It is working in three boxes perfectly fine but in one box it is not
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10072
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9885
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.