Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Dynamic Libraries

Posted on 2001-08-02
6
255 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery UI datepicker destroy 4 85
Identify Linux loader 67 181
How to ssh into my virtual box linux machine 4 163
looking for a CENTOS ISO to download with x window installed 2 50
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 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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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