Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dynamic Libraries

Posted on 2001-08-02
6
Medium Priority
?
261 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 300 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

885 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