LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-02-2010, 05:59 PM   #1
sepidev
LQ Newbie
 
Registered: Jan 2010
Posts: 4

Rep: Reputation: 0
Question C/C++ plug-in programming


Hi,
I wonder how to read the content of a shared object inside my c/c++ source code. Let me explain more.

Imagine i have a main.c file and it can get 2 int numbers and add them, then i compile this file using gcc and then i have an executable file.

after a while i notice that i like to add subtraction ability(function) to my simple program. there are 4 major way to do it:

1) adding the code inside to source file (main.c) and recompiling it.

2) creating another source file and implementing the new function into it, then compiling it as an static or shared object and the recompiling the main.c against this object file

3) using and embedding an scripting language, say perl or lua, to add the new functionality as scripts files into our executable program. this approach is useful in some situation, but here you have to force the end user to download another program (perl, lua, ...) to be able to run your app correctly, or it would lack a lot of functionalities, though you won't need to recompile your app.

4) embedding a peace of code, i mean new function into main.c to read and deal with the content of a directory, say "./plugin" at runtime and checking if there is any shared library within the directory, if any, reading their contents and adding the extra functionality to the main program on the fly.

so, my question is that how can we implement the fourth approach? in other words, how can we read the content of shared objects on the fly?
Last edited by opengl_cpp; 17 Minutes Ago at 02:07 AM..
 
Old 02-02-2010, 06:24 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Start from here: http://www.tldp.org/HOWTO/Program-Li...libraries.html .

Also,

man 3 dlopen

is your friend.
 
Old 02-03-2010, 03:19 AM   #3
sepidev
LQ Newbie
 
Registered: Jan 2010
Posts: 4

Original Poster
Rep: Reputation: 0
thank you, Sergei Steshenko.
i'll do it.
 
  


Reply

Tags
extension, plugin


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plug-in or Extension programming under linux/unix within c/c++ ? john.daker Programming 1 09-26-2008 11:27 AM
Plug-ins, Plug-ins, Plug-ins, those damn Plug-ins!! GRRRR!! Ausar Linux - Newbie 1 06-09-2004 04:10 PM


All times are GMT -5. The time now is 04:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration