Solved

Developing plugins: shmop vs dlopen

Posted on 1997-11-12
2
338 Views
Last Modified: 2013-12-26
I am trying to implement the concept of plugins for an application that we are writing.  I am thinking about using shared arenas to communicate between the main application and the plugins.  I'm new at this, and I'm not sure if this is the best way to go.  I have heard about dlopen, but I don't have alot of documentation on how to use it.

Which would be better to use, shmop or dlopen/dlsym?  Also, can anyone lead me to good resource on dlopen?

By the way, the application and plugins will be in C, and we are running IRIX 6.2.  And, platform portability is an issue; we want to be able to port to Windows NT.

Thanks,
Ash
0
Comment
Question by:chopin111297
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
jos010697 earned 100 total points
ID: 1295584
You can definitely use dlopen and friends. Compile and link
your plugin as a shared object (a dynamic link library). Check
your manuals for the appropriate linker flags. Suppose the
name of this shared object is 'foo.so' and it contains a
functions 'bar'. This is the way to run this function from
your main application:

typedef int (*fp_t)(int); /* a function poiner */

void* so_object;
fp_t  func;

if (so_object= dlopen("foo.so", 1)) { /* open shared object */
   if (func= dlsym(so_object, "bar") {  /* get address of bar */
      printf("bar42 returned %d\n", func(42));
   else
      printf("couldn't find bar: %s ...\n", dlerror());

   dlclose(so_object); /* close shared object */
}
else
   printf("couldn't open foo.so: %s\n", dlerror());

That's basically all there is to it:

1: dlopen() the shared object
2: retrieve the address of a function (or data) using dlsym()
3: close everthing afterwards using dlclose()
4: if an error occured, dlerrror() returns an error string

kind regards,

Jos aka jos@and.nl

0
 

Author Comment

by:chopin111297
ID: 1295585
Does anyone know of a good resource on the use of dlopen?
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question