Solved

Dynamic Libraries

Posted on 2001-08-02
6
252 Views
Last Modified: 2013-11-18
Hello

My Project is TurboIRC 3 , the sequel of TurboIRC 2000 ( www.turboirc.com ) , running under Windows and Linux .

Everything goes fine, but I want to add plugin support.

In Windows , I can load DLL's at run time and call their functions using LoadLibrary() and GetProcAddress().

My question is , 1. How to create such a shared library in linux ( e.g. Compiler options and 'exported functions' )  , and 2. How to load the libraries and call their functions from C++ .

Thanks a lot
0
Comment
Question by:WxW
  • 3
  • 2
6 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
ID: 6346789
1. use -shared option for gcc (and -G for ld)
   all functions which are note declared static are exported automatically
2. see man: dlopen, dlsym, dladdr, dlerror, dlclose
   (and don'r forget to add -ldl as linker option)

> How to load the libraries and call their functions from C++
Keep in mind that this is not the UNIX/Linux-way handling
dynamic shared objects.
UNIX/Linux does not load dynamic shared objects by program code using the function from 2. above (as M$), but the linker, respectively the runtime loader (ldd), will do it automatically.
0
 
LVL 6

Author Comment

by:WxW
ID: 6348587
Thats the problem.
The libraries have the same exported functions since they work as 'plugins' : anyone can make one without my application to know what the plugin is supposed to do.
So , linking the libraries at compile-time won't help. I need run-time code-based opening and calling.


0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6348641
2. see man: dlopen, dlsym, dladdr, dlerror, dlclose

with dlopen() you load the lib, with dlsym() you get the symbols (functions, variables, etc.) in there, a.s.o. ..
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:karouri
ID: 6388400
listening..
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6388897
are there some news, WxW?
0
 
LVL 6

Author Comment

by:WxW
ID: 6431153
y sorry for the delay ( vacation ! )

Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ubuntu 16.04 Emergency Boot 2 168
Issues with Ports in Linux (Hyper-V Guest) 2 98
BASH script to modify crontab? 3 49
WiFi Router device supports GPON! 3 29
I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
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…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now