[Solved] Can I read the info inside a *.dll and build it dynamically?

  • Hi,

    I'm making a gui app on a fedora system (unix) and I need to read a *.dll (i.e: myLibrary.dll) to load some of the information that contains inside. So the question is:

    • Is there a way to do it?
      • if YES can I then build the release with the dll dynamically so I just need the *.exe to run it?
      • if NOT do you know any 'simple' solution to get what I need?

    Thank you so much!

  • Lifetime Qt Champion


    What do you need to read from it ?

    Something's a bit mixed up, are you referring to linux's shared libraries (*.so files) or do you really want to read a windows DLL ?

  • @SGaist Hi, yes I know its a bit complicated. The thing is:

    • in my work, they have a program in windos that reads the content of a *.dll (besides other things).
    • In my case: I am doing a wizard app (which does other things different s than the windows program) on a fedora that has to run on a unix system.

    Until now was all ok but now my boss wants a new functionality which is the part of the windows program that reads a specific *.dll (made by them with another program). This dll contains some info and its updaated with new info once in a while and I need to load this info in my program.

    So now I don't know if there is a way to read that dll content or .... tell them to do another file for my case or.... tell them to re-build it in other way (dunno fi they can build it in another extension like *.so for example and if then will I be able to read it).

    Hope that now its more clear. If not, plese tell me.

  • @SGaist said:


    What do you need to read from it ?

    Something's a bit mixed up, are you referring to linux's shared libraries (*.so files) or do you really want to read a windows DLL ?

    *.so files are generated by Unix-like operating systems that use ELF like GNU. Linux is just a kernel.

  • Lifetime Qt Champion

    Are you binary reading these information from the DLL ?

    If you are expected to use that DLL on Fedora (or any other linux distro) then they will have to build it for it.

  • @SGaist I don't know how should I read it... in the case of the windows app it uses a delphi function to load the dll and does something like creating a pointer so you can access the functions inside the dll that returns the array of values I need

    I've copied the .dll file I need into my unix system and tried this code:

        QLibrary *myLibrary= new QLibrary();
        qDebug() << "myLibrary.filename" << myLibrary->fileName(); // returns  "/home/user/wk/folder1/Project/Resources/TheLibrary.dll"
        qDebug() << "myLibrary.load" <<  myLibrary->load(); // returns false
        qDebug() << "myLibrary.isLoaded" << myLibrary->isLoaded(); // returns false
        qDebug() << " qerrorstring! " << myLibrary->errorString(); // returns invalid ELF header

    So maybe I can read the *.dll this way but I still don't know how to deal with the errorString I got...

  • QLibrary can only be used to access dynamic libraries built for the OS you are running on. So, you can't open a Windows DLL on a Unix machine.

  • Lifetime Qt Champion

    Just one thing… Since this library is built for you, why do you need to do it like that ? Can't you just link against it ? Or is it some kind of plugin ?

  • @SGaist Well it is not built for me, its for another program in windows but they wanted to re-use it if possible with my program and avoid having to change it for me.

    @Meyer-Sound ohh... then I understood bad how QLibrary works. Thank you!

  • Lifetime Qt Champion

    Unless I misunderstood you, that library is built in-house even if it's from another department, right ?

    If so, why don't they provide you with the corresponding header and lib file so you can just use that library like any other ?

  • @SGaist yes that's it, but they wanted to avoid that if I could load it so first I "break my neck" with the problem. I've talk with them seeing that its totally impossible and I'm going to do it in another way for the moment.

    Thank you so much for your help!

  • Lifetime Qt Champion

    They will still have to build it for your OS. In any case you can take some inspiration from the OpenSSL code in Qt, they use the adequate method on each platform to use the DLL at runtime (unless you built Qt with OpenSSL linked)

  • @SGaist Nice! I'll keep it in mind. Thank you so much SGaist

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.