none
Visual C++: Problem with dependent DLLs

    Question

  • Hello,

    I compiled a custom DLL project using Visual Studio 2008 in C++. The compilation goes well and completes with no error. However, when I use Depends (dependencies walker), I see some dependencies problems:

    Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
    Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

    There are no *missing* DLL but four of them are listed in red:

    c:\windows\system32\GDI32.DLL
    c:\windows\system32\KERNEL32.DLL
    c:\windows\system32\NTDLL.DLL
    c:\windows\system32\USER32.DLL

    and also set of seven libraries that are delay-loaded are also shown in red:

    c:\windows\system32\ADVAPI32.DLL
    c:\windows\system32\DUSER.DLL
    c:\windows\system32\MPR.DLL
    c:\windows\system32\MSVCRT.DLL
    c:\windows\system32\RPCRT4.DLL
    c:\windows\system32\SHELL32.DLL
    c:\windows\system32\UXTHEME.DLL


    That makes me suspects that these DLLs may not be the right version but I am not sure. I had this project compiled and run fine on another computer until I had to change PC because of a major crash.

    Here are a few questions (sorry for the very basic questions, I am not a guru when it comes to dependencies on Windows, always frustrating)

    1- Why can I compile fine but not run on the same computer? Isn't the compiler validating that all symbols can be found before ending the compilation with 0 errors.

    2- Why do I have DLL showed in red in Depends? I mean the library is there but does not contain the right symbols? Does it seems to be a problem of library version as I suspect ?

    3- Is there a tool in windows to install automatically and recursively, from the web, all dependent libraries with the right version so that everyone is happy ( similar to "yum" in Centos) ? If not, how does one fix that kind of problem? Any way to tell which version of dependencies a DLL expects (it is obviously not enough to GDI32.dll on your PC, you must have the *right* one, but which one and how to fix the dependencies of GDI32.dll itself if I decide to install another version -- this seems like a endless problem).

    Any other suggestions to fix this kind of problems?

    Thanks in advance!

    Johnny


    Thursday, May 23, 2013 2:56 PM

All replies

  • This DLL may have a delay-load dependency on other DLLs. Have you tried running the exe that calls into this DLL?

    http://blog.voidnish.com


    Thursday, May 23, 2013 3:22 PM
  • 1- Why can I compile fine but not run on the same computer? Isn't the compiler validating that all symbols can be found before ending the compilation with 0 errors.

    Explain what you mean by "not run". Nowhere in your post do you explain this. What happens? Do you get an error message? If so what is it? Does  it crash? If so, what is the call stack?
    Thursday, May 23, 2013 6:40 PM
  • This library is actually a JNI library (Java native interface). When I try to run my java test program, I get this:

      The specified procedure could not be found

    The DLL is found (otherwise I get another message) but I cannot run it (getting instead the above message). It used to work fine on my old PC before the crash.  However, I did not have this series of errors with Depends...

    The error message is not very precise but, since I have those messages with Depends, it seems that I should fix that first.

    And yes, from the output of Depends, this library has delay-load dependency with other DLLs. It also has problem with non-delay DLL dependency (since my first posting). From those, 11 are problematic according to Depends. 

    If I run GDI32.dll in Depends (one of my non-delay dependency problem), I get this other list of problematic dependencies:

    GDI32.DLL
    KERNEL32.DLL
    NTDLL.DLL
    USER32.DLL
    ADVAPI32.DLL  (delay)
    DUSER.DLL (delay)
    MPR.DLL (delay)
    MSVCRT.DLL (delay)
    RPCRT4.DLL (delay)
    SHELL32.DLL (delay)
    UXTHEME.DLL (delay)

    Now, I am trying to install a new fresh PC. I think that this PC is just in a strange state. Unless someone can propose a quick fix to my problem.

    Friday, May 24, 2013 5:13 PM
  • To repeat a part of my reply to Nishant, this library is actually a JNI library (Java native interface). When I try to run my java test program, I get this:

      The specified procedure could not be found

    The DLL is found (otherwise I get another message) but I cannot run it (getting instead the above message). It used to work fine on my old PC before the crash.  However, I did not have this series of errors with Depends...

    Hence my question: if I can compile fine, why do I still have problems with depends on the very same PC? Is it a problem with the system path settings, the compiler and my test program dont use the same libraries?

    Friday, May 24, 2013 5:15 PM