none
Visual C++ 2005 Runtime Issue (Unexpected DLL Loading Error)

    Question

  • I am attempting to create an application using a DLL created by the Matlab Compiler Runtime.  The main DLL of the Matlab Compiler runtime is mclmcrrt710.dll which was apparently built with Visual C++ 2005.  When trying to run my application, the DLL fails to load.  When using Dependency walker to debug the problem, I saw some strange results.  mclmcrrt710.dll directly depends on MSVCR80.DLL and MSVCP80.dll, and they both load successfully from the proper SxS directory, however MSVCP80.dll has a dependency on MSVCR80.dll that is unsatisfied.  This is very surprising to me, I don;t understand how the DLL could load once successfully and then fail all within the same process.

    Using Procmon.exe, I see the DLL loaded successfully from the SxS directory, but later in the log I see failed attempts to load it (Operation:QueryOpen, Result:NAME NOT FOUND) from the current directory and each directory in %PATH% with no attempts to get it from the SxS directory (where it resides, and thus would be successful).

    Adding MSVCR80.dll somewhere in the path allows the program to load; but, as expected, generates a R034 runtime error for loading the DLL without a manifest.

    I have tried the following, which did not solve the issue:

    • Uninstalling all VC2005 runtimes and reinstalling
    • Adding manifests calling out the VC80 CRT to everything in the chain (my exe, my dll, and mclmcrrt710.dll)
    • Modifying the SxS policy files to force it to load a different version of the CRT 

    A screenshot of Dependency Walker showing the unexpected behavior:

    Friday, August 05, 2011 6:31 PM

All replies

  • Hello,

     

    First, did you have the access license of the MATLAB DLL? As far as I know, if you do not have the access license, you can not import these DLLs into your project.

     

    Second, as far as I know, the MATLAB can create a C++, .NET or Java project through itself, we need not to include the runtime DLL by ourselves. If you want to know more about this, you can ask a question in the MATLAB's website: MATLAB Answers

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 08, 2011 7:05 AM
  • Yes, we do have a proper license for the Matlab Compiler, however the runtime library does not require a licence to be deployed on target machines.  I am fairly certain that this is not a licensing issue since the only reason it fails to load is the unsatisfied dependency on MSVCR80.dll.  Do you have any theories as to the cause of the strange DLL loading behavior that I observed?
    Monday, August 08, 2011 4:18 PM
  •  

    Second, as far as I know, the MATLAB can create a C++, .NET or Java project through itself, we need not to include the runtime DLL by ourselves. If you want to know more about this, you can ask a question in the MATLAB's website: MATLAB Answers

    Regardless of how the interface into the Matlab is created, the mclmcrrt710 dll will need to be loaded, as it provides the functions to allocate and populate Matlab objects.  There may be other ways to create an interface, but they will all end up using the same low-level functionality.  As you can see in my screenshot, the dll that provides this low-level functionality cannot load, even in isolation.  This problem may not be related to Matlab at all.
    Monday, August 08, 2011 4:27 PM
  • Yes, we do have a proper license for the Matlab Compiler, however the runtime library does not require a licence to be deployed on target machines.  I am fairly certain that this is not a licensing issue since the only reason it fails to load is the unsatisfied dependency on MSVCR80.dll.  Do you have any theories as to the cause of the strange DLL loading behavior that I observed?


    1. Only, maybe, because your version of runtime is not the latest, or tweaking the manifest was not perfect (it's very confusing and can be thwarted by some esoteric #defines..). Are you sure you've installed the latest vc2005 runtime, either globally or locally?

    2. Can you make a _minimal_ app that uses this DLL, and see if it loads well?

    --pa

     


    Tuesday, August 09, 2011 2:26 AM
  • Hello,

     

    Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 12, 2011 8:29 AM