Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:04:23+00:00 2026-06-10T10:04:23+00:00

If I use dlopen on the same lib/file two times in the same application-run,

  • 0

If I use dlopen on the same lib/file two times in the same application-run, will it yield the same handle in both cases? Is there any guarantee for this (a short experiment showed that it at least does on my box)?

I’m currently playing around with a little plugin-system (out of curiosity) and if there would be some kind of guarantee for this observed behaviour I could use this address as a key for a plugin to prevent duplicated loads.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:04:24+00:00Added an answer on June 10, 2026 at 10:04 am

    Yes. The dlopen(3) linux man page says:

       If the same library is loaded again with dlopen(), the same file 
       handle is returned. The dl library maintains reference counts for 
       library handles, so a dynamic library is not deallocated until 
       dlclose() has been called on it as many times as dlopen() 
       has succeeded on it.
    

    BTW, on Linux systems, you can dlopen a lot (many dozens of thousands) of shared libraries, as my example manydl.c demonstrates. The main limitation is address space.
    So practically, not bothering about dlclose-ing stuff is possible.

    (unless your dlopen-ed shared libraries have weird or resource consuming constructor or destructor functions)

    Added in December 2017:

    Notice that what is relevant is the exact path string passed to dlopen. So if you use "./foo.so" and "././foo.so" (or "../foosymlink.so" where foosymlink.so is a symlink to foo.so) the dlopen-ed handles are different, and in some cases weird behavior of the two instances of that shared library might happen.

    added in june 2019:

    Read also Drepper’s How to write shared libraries paper (it explains also well how to use them!).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone help me to know how can i use dlopen to get handle
use C#,want to upload excel file on google doc. bellow syntax use to upload
I use one c++ dll in my python code. When I run my python
Derek-MacBook-Pro:example derek$ rails g /Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError) Referenced from:
I've created shared library (will be used like plugin). There are a lot of
I am trying to use 'py2app' to generate a standalone application from some Python
I am trying ti use carrierWave. I have installed imagemagic using homebrew and both
I am trying configure a Django application to use mysql. I want to use
If I build a shared library (shared object) I can use it in two
One can design plugins in C using 2 techniques (AFAIK): Use dlopen() all the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.