Reputation: 22319
This project consists of a single .cpp file which calls LoadLibrary() to load a dll-file.
What happens is that if I run the following through the Microsoft Visual Studio 2012 Command Prompt:
cl /nologo Test.cpp
Everything works fine.
On the other hand, if I start up a simple Visual C++ project, add the file and compile it through there, the LoadLibrary() call fails with code 126: The specified module could not be found.
The .exe I build from the command line is more than twice the size of the one built in Visual Studio. So I guess there's some static linking going on.
The .dll-file is fine, and it's in the same directory as the .exe-file.
Upvotes: 5
Views: 21653
Reputation: 29
does your operating system is 64-bit it?
I have encountered this situation on my win7(64-bit), but not in VS,photoshop(64-bit), matlab-2011a(64bit). Prompts are the same: Loadlibrary failed with error 126 ...
As far as I know,“they’re missing a registry entry critical to its functionality. Specifically, whenever an application requests OpenGL access, AMD’s atig6pxx.dll kicks in. It then peeks inside HKLM\SYSTEM\CurrentControlSet\Control\Class{4d36e968-e325-11ce-bfc1-08002be10318}\0000 and loads the OpenGL component as specified by OpenGLVendorName (64-bit) or OpenGLVendorNameWow (32-bit).”
You can refer to this blog(enter link description here), and it gives the solution。I tried and it worked.or you can refer to this forum(enter link description here)。
I hope it could solve your problem,go luck:)
Upvotes: 0
Reputation: 531
if Loadlibrary function fails with error 126 that clearly shows that it was not able to find the library. so you can check this function by appling full path in Loadlibrary's argument. if it works then set that path in PATH variable of system environment variable. because Loadlibrary api first find that full path, if it was not able to find the library at that path then it search it in systems standard PATH.
Upvotes: 2
Reputation: 22319
I figured it out.
By default the cl command uses the multibyte character set. While new projects set up in Visual Studio are configured for unicode.
Upvotes: 8