I am using Visual Studio 2010 in x64-based processor.
I got error LoadLibrary(_T("xx.dll")) with 126.
I tried dependency Walker to find out all .dll and module, function dependencies. It shows everything is fine.
Actually old code was working fine in 32bit operating system and compiled. After I moved to 64bit operating system, There is an error.
I copied all the .dll libraries in same directory with .exe file.
Is there any conflict between compiled xx.dll in 32bit then after execute at 64bit?
Thank you so much for any suggestion and advice.
64bit applications can't load 32bit DLLs, WOW64 (windows 32bit emulation on 64bit) just works for spawning processes/executables, not what happens on runtime. Already answered multiple times on SO, like here.
You need to compile/get 64bit versions of your DLLs.
Related
I am compiling a dll in visual studio 2017 c++.
SDK: 10.0.17134.0
this project uses a template, that automatically creates 2 dll, one for 32 bit and one for 64 bit. I do have two machines that run the same software but have different hardware and OS.
First machine has a intel i7 and runs windows embedded standard 64 bit
the second machine has a intel atom and runs windows embedded standard 32 bit
On the 64 bit machine, both dll work. (32 bit and 64 bit), on the atom the 32 bit does not work tough. I do not have any error messages, the only thing i get from the software is that it is not compatible without any additional clues. The software is the same on both systems so I assume that the problem is related to the OS or the processor.
the software I am developing for is a vision system by omron so it is nothing that is available online or that can be shared here.
What could be the cause for this? If you need additional information just ask.
Generally, in order for an executable file (either an .EXE program or a .DLL support module) built using the MSVC C/C++ compiler in Visual Studio 2015 or later, to work on a target PC, you need to have the latest VC++ Redistributable run-time libraries installed on that PC.
See also this discussion on Stack Overflow.
I have a program that I have no problems with, and it compiles on my a computer that I have which runs windows 7 32bit. To run the program, I have to use a library, which I have the .h and the .lib files for.
I needed to make a small change to the program, just changing some of the text output on the help screen, but I was doing it from another computer, which is running windows 7 64bit. When I attempt to compile the program, without making any changes to the code, just copying the files over to the new computer from dropbox, I get "LNK2019: unresolved external symbol ..." for some of the functions that I am calling from the library.
For compiling, I am using Qt Creator, and calling on the microsoft visual studio compiler (I use the same on both computers, except of course that one is x64 and the other x86).
Has anyone encountered an issue similar to this in the past? If so, what did you do to fix it?
Almost certainly your problem is your make files/build system.
Either you are targeting 32-bit standard libraries that don't exist on the 64 bit platform.
or you have copied 32-bit libraries from the other system and are linking to 64 bit libraries on the new system
How do I know if the program I am writing in C++ will run properly in a 32-bit OS or not?
(without manually testing in one)
I am using Visual Studio and compiling in a 64-bit machine. Will that stop the program from working in other machines?
And what about the processor and Windows version? Will the binary be compatible with most Windows versions and processors, if the program just does a few simple things such as web requests and calculations, with a simple user interface?
My program doesn't have to be 64-bit. I would just like to create one binary that runs in most computers, like those I download every day on the Internet. How could I do that?
If you are building your code specifically for 64-bit Windows, you can't expect the binary to work on 32-bit Windows. That will require a separate build.
An executable compiled and linked for 64-bit will typically also require 64-bit libraries.
Use tools like the Dependency Walker to find out, if a given executable is refering to 32- or 64-bit libraries.
In Visual Studio, the "target platform" decides which CPU architecture you are targeting. It is perfectly feasible to create 64-bit executables on a 32-bit system, but you can't actually run them on such a machine.
You can do what's called cross-compiling i.e compiling on one machine for another. How to compile a 32-bit binary on a 64-bit linux machine with gcc/cmake This is what you're after if I read you correctly. There should be a Windows equivalent.
My C++ IDE is Visual Studio 2012 Express Version, and my Python IDE is Aptana3 (64-bit). My computer is Windows 7 64-bits.
I've write a .dll with C++ (Win32 console application), which basically follows the instruction at MSDN. It works well when I call it with a C++ application.
Then I try to call it from Python by following codes:
import ctypes
d = ctypes.WinDLL("C:\\DynamicLibrary\\Debug\\MathFuncsDll.dll")
However, I've got following error:
File "`<pyshell#8>`", line 1, in <module>
d = ctypes.WinDLL("C:\\DynamicLibrary\\Debug\\MathFuncsDll.dll")
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application
I've googled about this error message, and some posts say it because the compatibility between 32- and 64-bits. But I doubt it, since my IDE's and system are all 64-bit.
May I know what am I wrong?
Many thanks in advance. :)
The most common explanation for that error is that the system is attempting to load a 32 bit DLL into a 64 bit process, or vice versa. The fact that your system is 64 bit just makes that diagnosis more likely. Perhaps your Python is 64 bit, but the C++ project outputs a 32 bit DLL. Or vice versa.
In the question you state that your Python installation is 64 bits. In which case you need to look at your C++ project. What platform are you targetting? Win32 or x64? My money is on the answer to that question being that you target Win32.
That's the most likely explanation. Beyond that the next most likely cause is the exact same problem, but for one of the dependencies. The Python process and the DLL match, but when resolving the dependencies of the DLL the loader finds a DLL of the wrong bitness.
I've googled about this error message, and some posts say it because
the compatibility between 32- and 64-bits. But I doubt it, since my
IDE's and system are all 64-bit.
Yes, your research is correct.
My C++ IDE is Visual Studio 2012 Express Version,
My computer is Windows 7 64-bits.
That doesn't guarantee that you would build a 64 bit binary. Infact, VS 2012 IDE is a 32 bit application. Its the compiler and the CRT which is responsible to generate a 64 bit binary. And moreover the default settings for Visual Studio is to generate a 32 bit binary
You can easily google and determine how to build a 64 bit binary using Visual Studio. Alternatively, refer the link How to: Configure Visual C++ Projects to Target 64-Bit Platforms
and my Python IDE is
Aptana3 (64-bit). My computer is Windows 7 64-bits.
That still doesn't say anything about your Bitness of your Python Installation .
When in doubt, check for the bitness of your dll and your python.exe. You can easily determine the bitness using dumpbin
C:\Python27>dumpbin /headers python.exe|grep "machine"
14C machine (x86)
Build your C code to X64 version
I tested it and actually works well
Here is my problem:
I have developed an application which can be run on various platforms, including Windows and Unix. This app runs well on pure Win32 box (WinXP) or a pure Win64 (Win2K3 x64 edition) and other unix platforms.
It only fails when running on a 64 bit Win2K3 in 32 bit mode. This app invokes a third party dll at the runtime. And the third party dlls are not formally installed, but just copied to a location in the same env. I'm also sure I'm having the right version of these 3rd party dlls (I mean 32 bit version for 32 bit mode). Even I manually set the "path" in this testing box, it still doesn't work. The app is compiled and built in 32 bit mode in this Win2K3 box.
I run dependency walker and see the same error. Cannot find that 3rd party dll.
Can anyone shed some lights on this? How do I make that 3rd party dll path visible to my app or the system?
I would suggest you to do the following:
ensure that you are using 32-bit
version of the problematic DLL with 32-bit app
use filemon to see what paths your
application tries while loading that
DLL
check whether it works if you place
that DLL into one of those paths
use dependency walker with that DLL
itself - it might have its own unresolved
dependencies
WOW64 redirects all calls by 32 bit applications to the System32 folder to the SysWOW64 folder. Is the third party DLL in the system32 folder? Because the system32 folder, contrary to what you'd expect, contains ONLY 64bit DLLs on Windows x64.