Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


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

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

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, 05:24 PM   #2
Sergei Steshenko
Senior Member
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Start from here: .


man 3 dlopen

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

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


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 10:27 AM
Plug-ins, Plug-ins, Plug-ins, those damn Plug-ins!! GRRRR!! Ausar Linux - Newbie 1 06-09-2004 03:10 PM > Forums > Non-*NIX Forums > Programming

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

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