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.
You may encounter the loadlibrary failed with error 126 when the problematic application does not have the privileges to access a protected system resource. In this case, launching the problematic application as an administrator may solve the problem.
Kernel32. dll is loaded into every Windows process, and within it is a useful function called LoadLibrary .
If a DLL fails to load, there can be numerous reasons for the error, listed below are the most common. The DLL or referenced DLL is not in a directory specified in the path. The DLL references another DLL that is not present. Hard disk error has corrupted or damaged a DLL file.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With