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 6844729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:24:49+00:00 2026-05-27T00:24:49+00:00

I just dont get it, why line 22 is failing to compile? #include <stdexcept>

  • 0

I just dont get it, why line 22 is failing to compile?

#include <stdexcept>
#include <dlfcn.h>
#include "Library.h"

int main(int argc, char *argv[])
{
    try
    {
        void* libHandle = 0;

        libHandle = dlopen("libExpandableTestLibrary.so", RTLD_LAZY);
        if(!libHandle)
            throw std::logic_error(dlerror());

        std::cout << "Libary opened gracefully" << std::endl;

        void* fuPtr = 0;
        fuPtr = dlsym(libHandle, "createLibrary");
        if(!fuPtr)
                throw std::logic_error(dlerror());

        Library* libInstance = static_cast<Library* ()>(fuPtr)();
        // Tutorial: http://www.linuxjournal.com/article/3687
        // Tutorial Code: shape *my_shape = static_cast<shape *()>(mkr)();
        // Compiler error message:  Application.cpp:22:56: error: invalid static_cast from type ‘void*’ to type ‘Library*()’
        libInstance->Foo();

        dlclose(libHandle);

    } catch(std::exception& ex)
    {
        std::cerr << ex.what() << std::endl;
    }
}

Any help is welcome
If you need additional information’s just let me know.

  • 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-05-27T00:24:50+00:00Added an answer on May 27, 2026 at 12:24 am

    I take it that fuPtr points to a function that is supposed to return a pointer to a Library object (given the name loaded is "createLibrary").

    In that case, the line including your cast needs to look like this:

    Library* libInstance = reinterpret_cast<Library* (*)()>(fuPtr)();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just don't get it. Tried on VC++ 2008 and G++ 4.3.2 #include <map>
I'm trying to retrive a dataset to a Gridview, but I just don't get
In another question, Mark speaks highly of IDEs, saying some people still just dont
I just installed valgrind but now my breakpoints dont work in qtcreator. How can
Not a question but i dont have a blog and i have just created
im just starting with lift and scala and have a problem i dont realy
I have been trying to get a string between two strings in a line.
Im reading the mongodb guide, but I dont get this: mongodb://fred:foobar@localhost It says I
I just don't understand what's happening, I haven't change anything to the site for
Maybe I just don't know .NET well enough yet, but I have yet to

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.