Results 1 to 4 of 4

Thread: Cannot load DLL.

  1. #1
    Join Date
    Jan 2013
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Cannot load DLL.

    I am using Qt 4.7 on a Windows 7, 64-bit machine. I am trying to load a third party DLL. In their source file they call LoadLibraryA(functionName) to load the library at run time. The code checks for a handle returned when the DLL is loaded.

    This is my problem: Every time I run my code it gets to the point of loading the library but the returned handle value is NULL. This causes the program to crash (Segmentation fault). In my application output window I get "(Internal error: pc 0x0 in read in psymtab, but not in symtab.)".

    The twists: Originally another programmer integrated the third party code into the application and the application runs just fine on his machine. I am using his code exactly and I get the crash. I tried the application on a 32-bit laptop. Originally it did not work. However when I uninstalled Qt 4.7 and reinstalled it, the application works. (This may be a red herring....)

    Debugs I have tried: 1) I have tried using Dependency Walker. The results I get when I run DW on my application exe are the same ones he gets. 2) I have uninstalled and re-installed Qt on my machine 3) I have verified that the DLL is in the same directory as the executable

    Any thoughts?

    Thanks.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Cannot load DLL.

    Is your Qt app compiled as a 64-bit app? Is the third-party DLL a 64-bit DLL? On Windoze 7, all executable parts (exe, dll, etc.) must be all 64-bit or all 32-bit. You can't mix and match 64-bit and 32-bit like you could with 32-bit and 16-bit code on Windows XP.

    If the 3rd-party DLL is 32-bit, try recompiling your app (and Qt) in 32-bit mode (or get someone else to do it with a 32-bit compiler and Qt) and see if that makes a difference. A 32-bit app with all dependencies also 32-bit will run just fine on Win 7.

  3. #3
    Join Date
    Jan 2013
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot load DLL.

    Is your Qt app compiled as a 64-bit app? Is the third-party DLL a 64-bit DLL? On Windoze 7, all executable parts (exe, dll, etc.) must be all 64-bit or all 32-bit. You can't mix and match 64-bit and 32-bit like you could with 32-bit and 16-bit code on Windows XP.
    The third party DLL is a 32-bit DLL. I am relatively new to all of the nuances for compiling applications, but I believe that my app is being compiled as 32 bit. In my Project settings, my qmake command line is: "qmake.exe My_App.pro -r -spec win32-g++" and my make command line is: "mingw32-make.exe -w in C:\My_App_Build_Directory".

    If the 3rd-party DLL is 32-bit, try recompiling your app (and Qt) in 32-bit mode (or get someone else to do it with a 32-bit compiler and Qt) and see if that makes a difference. A 32-bit app with all dependencies also 32-bit will run just fine on Win 7.
    The other computer on which I can get this to work is a 32-bit machine. I checked the qmake and make command lines on this machine and they are the same as on the machine on which the app does not work.

    I went back to Dependency Walker to check again for missing dependencies. DW showed that the third party DLL needed "msvcr100d.dll" and "msvcp100d.dll" and that I was missing these. I believe they are part of MS Visual Studio. I already have MSVS Redistribution for 32-bit and 64-bit installed on my machine but apparently these files don't come with the redistribution package. I was able to get the two DLL's from a co-worker that does have the full MSVS install and I put them in my windows\system32 directory. Dependency Walker shows that the DLLs found (though it does not indicate they are 64-bit). Even with these two DLLs in place the app still crashes.


    Added after 1 7 minutes:


    Okay, I think it is working now. I ended up installing a demo version of MS Visual Studio 2010. Now the DLL loads and runs. I returned to using Dependency Walker and compared the DW output for from the computer that the application worked on and my computer and found two missing MSVC files that I hadn't noticed before. I had installed the redistributable package earlier but apparently it doesn't put these files in place for you.
    Last edited by cmp1104; 4th April 2013 at 21:49.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot load DLL.

    Quote Originally Posted by cmp1104 View Post
    The third party DLL is a 32-bit DLL. I am relatively new to all of the nuances for compiling applications, but I believe that my app is being compiled as 32 bit. In my Project settings, my qmake command line is: "qmake.exe My_App.pro -r -spec win32-g++" and my make command line is: "mingw32-make.exe -w in C:\My_App_Build_Directory".


    The other computer on which I can get this to work is a 32-bit machine. I checked the qmake and make command lines on this machine and they are the same as on the machine on which the app does not work.

    I went back to Dependency Walker to check again for missing dependencies. DW showed that the third party DLL needed "msvcr100d.dll" and "msvcp100d.dll" and that I was missing these. I believe they are part of MS Visual Studio. I already have MSVS Redistribution for 32-bit and 64-bit installed on my machine but apparently these files don't come with the redistribution package. I was able to get the two DLL's from a co-worker that does have the full MSVS install and I put them in my windows\system32 directory. Dependency Walker shows that the DLLs found (though it does not indicate they are 64-bit). Even with these two DLLs in place the app still crashes.


    Added after 1 7 minutes:


    Okay, I think it is working now. I ended up installing a demo version of MS Visual Studio 2010. Now the DLL loads and runs. I returned to using Dependency Walker and compared the DW output for from the computer that the application worked on and my computer and found two missing MSVC files that I hadn't noticed before. I had installed the redistributable package earlier but apparently it doesn't put these files in place for you.
    sharing the debug versions of those dlls is not allowed! You are breaking terms of services and copyright etc.

    The solution is to stop using debug versions and use release build for deployment.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Replies: 6
    Last Post: 4th March 2013, 21:20
  2. 100% CPU load
    By kartun in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2011, 08:11
  3. DLL won't load
    By waynew in forum Qt Programming
    Replies: 8
    Last Post: 25th October 2010, 02:48
  4. Save to SVG and load from it
    By Radagast in forum Qt Programming
    Replies: 3
    Last Post: 14th June 2008, 15:22
  5. Qt4 does not load JPG's.
    By Teuniz in forum Qt Programming
    Replies: 3
    Last Post: 4th September 2007, 00:06

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.