Cannot load library error 126

Posted on 2011-03-21
Last Modified: 2013-11-27
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?




Question by:Carlos1976
  • 3
  • 2
  • 2
LVL 33

Expert Comment

ID: 35181348
the dlls were looked for in the folder where the application executable resides, then in windows and system32 folders, then in folders of path environment variable.

though called 'library' the library paths of visual studio are for object libraries only, not for dlls.

LVL 44

Expert Comment

ID: 35181399
>>Visual Studio Express

Three points.
1)  As far as I understand it there isn't built in support for MFC, so I don't understand how you are using the options concerning MFC in the build.
2)  Also you might be in breach of your licence agreement with trying to distribute something to other PC's
3)  Just copying dll's (which you  might or might not be allowed to distibute - another potential breach of licence) isn't a good way to distribute your application - some need registering for instance.
LVL 33

Expert Comment

ID: 35181548
you may download VS2010 runtime at the target computer. it is free. installing it should solve the dll issues.

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.


Author Comment

ID: 35181744
Thanks Sara and Andy,

Well the customers who will use this DLL file will not install the VS2010 runtime, but thanks for this useful information Sara. I will try it on my other PC. :-)

Andy, to create product in VS Express is legal even if the product will be sold or other computer will use. But I got info that Express adds some interesting part to your application (which was created by it) on the way that you can not use on other PC. I do not know and was surprised but maybe.
I use MFC realted part in my main dll code so the MFC is used and I set the MFC static libray so my DLL should include the corresponding MFC part as static.

I do not know the answer yet but thanks for help both of you!
If you have any idea juts share it with me, please!


Author Comment

ID: 35181876
Hi Andy again,

A little bit completion for selling.
I can sell but only if I give the source code too.
It menas that probably I have to see other program than VS Express.
Can you advice me a similar program, please?



LVL 44

Expert Comment

ID: 35181930
VS professional, same environment, you can distribute, MFC should be fully supported.  (Even comes with a licence for a version of Install Shield which you can download - so you get a program you can use to create installations)
LVL 33

Accepted Solution

sarabande earned 500 total points
ID: 35182082
when the customers do not install vs2010 runtime, you could do it with your setup.

i checked my xp system for your dlls and they were missing. seems they were part of ie8 (which i haven't installed). you can freely download them from various sides. check the copyright whether they can distributed.


Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Configure a Local PHP Interpreter for Phpstorm 2 248
Why is "packages element is not declared"? 2 211
c++, dynamic object by json 1 42
Android development question 2 34
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question