Solved

Dynamic Libraries

Posted on 2001-08-02
6
249 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

19 Experts available now in Live!

Get 1:1 Help Now