cannot load library error code 126


  • Hi all!


    I have a big problem.

    I developed a DLL file for MetaTrader via Visual Studio Express 2010 C++.

    Metatrader is a forex trading program which is programmable and can use any DLL file by import function.

    I have used the VS express on Windows 7 x64 op system.

    The express can not use x64 (as I know) so everything is built as x86 (32bit), I have checked it via Properties (management).

    The problem: I built DLL file on my machine and it is working perfectly under MetaTrader but only on my machine. (perhaps VS copied some needed files)

    When I tried it on other machine (WIn XP (x86)) then I got an error message: cannot load library error 126

    Dependency Walker shows the following DLLs are missing (only on WIN XP machine):






    I downloaded them and put to experts/libraries (next to my dll file).

    (metatrader can find any DLL which copied to this 'libraries' )

    The problem still exists.

    I changed the Use of MFC from shared to static in VS and rebuilt the DLL.

    VS settings:

    Properties/Configuration Properties/General/Use of MFC=Use MFC in a Static Library

    Properties/C++/Code Generation/Runtime Library=(/MDd)

    I set these ones what I gathered of forums, etc...

    The problem still exists. (DLL files are missing further)

    I think it is a compier setting problem but I do not know what.

    Do you have any advice for me?





    Monday, March 21, 2011 12:17 PM

All replies

  • Don't know if it helps, but /MDd is a debug library.  Make sure you select the correct option.  I usually use Multithreaded (static linking).
    Thursday, March 24, 2011 4:04 AM
  • Hi Carlos,


    Based on your description, it is hard to say whether it is a compiler issue or operation system issue. Could you tell me some more detail about you issue? For example.  which WinAPI you have called?


    In additional , here is some other information about these dll:

    1. ieshims.dll is an artefact of Windows Vista/7. ieshims.dll is used to proxy certain calls like CreateProcess and hand protected mode IE which doesn't exist on XP. So it is unnecessary.

    2. wer.dll is related to Windows Error Reporting and it is probably unused on Windows XP which has a slightly different error reporting system than Vista and above.

    3. bcrypt.dll and ncrypy.dll are Windows Cryptographic Primitives Library

    4. You can use a macro definition like #ifdef to make a distinction between different windows version.


    I’m glad to receive your reply and help you to solve your issue


    Best Regards,


    Rob Pan [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.

    Thursday, March 24, 2011 8:38 AM