Compiled dll not working on intel Atom 32bit - c++

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.

Related

Compile 32 bit and 64 bit application (with same code) into one exe

I have 2 applications that uses global hooks, and its built for Windows 10 (64 bit). One is 32 bit and the other is 64 bit. I am able to compile them into 2 separate exe files that work independently. But since they have the same code, I wish to compile them into one exe file that will cater to both it's 32 bit and 64 bit responsibilities. Can I do that using Visual Studio or other means?
The Windows PE EXE format does not support multiple CPU architectures in a single binary.
The SysInternals tools embed the 64-bit .exe as a resource in the 32-bit executable and extracts and runs that if IsWow64Process is true. If you choose this technique you must also take into account that the recent ARM64 machines are Wow64 but only emulate 32-bit x86 applications.
Note: Windows Server Core can be installed without Wow64 support and you must also distribute the 64-bit binary if you support those systems.

Compiling Tesseract OCR on 64 bit Windows

I'm trying to compile Tesseract OCR into a Windows 64 bit version of the library. I've downloaded the source and got it compiling to a 32 bit version using Visual Studio Express C++ 2010, but as I'm not usually a C++ programmer, I'm at a loss as to how I move over to compiling a 64 bit version.
Any help would be really appreciated.
The reason I need a 64 bit version is that I'm using it as part of a Java project that requires a 64-bit JVM. The 32 bit version of Tesseract clearly won't work in the 64 bit JVM, but there doesn't seem to be an official 64 bit Windows build.
The relevant 64-bit DLLs are provided by Tesseract .NET wrapper project. You may want to check out its solution/project configuration to see how the DLLs are compiled.

Calling customized C++ dll from Python

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

32 bit library on 64 bit system

Can it cause any problem if I use 32 bit library on a 64 bit system?
What could be the incompatibilities?
I know this question is too vague. An example :
I tried to setup FreeGlut 32bit library with VS2010 on windows 7 64bit. There were a lot of issues at first.So, I was looking for 64bit of FreeGLUT, thinking 32bit FreeGlut might conflict with 64 bit windows. But later on I managed to run my 32bit FreeGlut with my 64bit windows without any problem.
Question is, if there are any thing in the program, that we should look into while using those libraries which doesn't match with the system. (32bit library on 64 bit OS)
64 bit Windows is fully capable of running 32 bit applications. In fact, the default configuration for Visual C++ is to build an x86 application regardless of the operating system it is running on.
There are some gotchas you have to be aware of when running a 32bit app on 64bit Windows. For instance, there's registry redirection (to avoid it you pass KEY_WOW64_64KEY to e.g. RegOpenKeyEx). There's filesystem redirection, too. These are important things to have in mind when you are reading system configuration values, for example.
Also, be aware that you can't mix 32 and 64 bitness in the same process. Your 32bit app can't use 64bit DLLs or static libraries.
Visual studio can compile for 32 bit or 64 bit based on the project setting.
Probably, Question you mean to ask is about Linking 32-bit library to 64-bit program
The answer is:
You can't directly link to 32bit code inside of a 64bit program.
The only option is to compile a 32bit (standalone) program that can run on your 64bit platform (using ia32), and then use inter-process communication to communicate to it from your 64bit program.
It's not about the operating system- Windows doesn't care if your code is 32bit or 64bit. It matters that your process is the same bitness as all libraries it cares to load- and they must all be the same bitness.
You might be interested in this link explaining common compiler errors when porting to 64-bit. It might help you solve your problem.
To try to answer your question more directly, there are things that might make 32 bit libraries break in a 64 bit environment, but that's too much information to share in a SO answer.
This link is the MSDN index related to development for 64 bit systems and might interest you as well.
Your question could be about how to develop specifically code that will run natively on 64-bit versus 32-bit hardware. There is info on that here. In particular you would have to follow the instructions here to enable 64-bit build tools.
If you are building 64-bit binaries, you will need to link with 64-bit libraries. Note that 32-bit binaries should run just fine on 64-bit Windows, so you may not need to go to this trouble.

Credential manager for Vista/Windows 7

I have Credential manager implemented in VC++ which captures credentials during login process. It works well in XP/Vista/Windows 7 32 bit env. But is not working in 64 bit.
Any idea ?
Thanks in advance for any help
If you want your DLL to be loaded by a 64-bit process, your DLL has to be compiled for 64 bits.
If you want your DLL to be loaded by a 32-bit process, your DLL has to be compiled for 32 bits. This is true on both 64-bit Windows systems and 32-bit Windows systems.
John gave you a useful link, even though John's wording is wrong. An application (exe) which is built for 32 bits will run in 64 bit Windows, but it can only load 32-bit DLLs.
Did you build for a 64-bit platform in Visual Studio?
A Visual C++ application which is build for a 32-bit environment won't work directly in a 64 bit environment. And although applications will work using the WOW64 compatibility layer, DLLs must be 64-bit if they are to be loaded by a 64-bit operating system.
Since that is indeed the case here, you need to build your project for a 64-bit platform (Visual Studio 2005 and later have a 64-bit compiler).
See the link http://msdn.microsoft.com/en-us/library/ms185328.aspx for more details.