C++: MFC Application on both Windows 10 x64 & Windows 7 x64 - c++

I'm building MFC Application with CLR which can run on windows 10 x64 & windows 7 x64 and execute without installing Visual Studio.
First, I've tried to find a solution for app without installing visual studio.
After some works on google, I found some clues to this issue.
Release build doesn't require installing Visual Studio.
I was building the project on windows 10 x64. So the release version can work on other windows 10 pcs without Visual Studio.
But it can't work on Windows 7.
So I've got stuck in search on this issue until now and I found something.
"Build applications for both Windows 7 and Windows 10 with Visual Studio 2015" is a thing I found here.
The answer is right thing I've tried.
On their comment, I saw one word - CMake.
I'm not sure that I can accomplish my solution with this - CMake.
Is there someone to told about this thing?
Or anyway to fix this issue?
Thank you.

CMake won't help you.
I think you'll need to install Visual C++ Redistributable for Visual Studio 2015 on any machine where Visual Studio was not installed, if the redistbutable package was not installed yet.
You also need to use .NET framwork which installed on both machines, I guess .NET 4 is good enough.
EDIT:
Try to run your exe from a console, and check if there is some print for missing dll or something.
Anyway, you can use dependency walker to check if you're missing some dlls, (download the x64 version) drag&drop your exe into it and check what prevent it from run.

Now, I found right solution about this m own question.
As a matter of fact, #SHR is helpful for this answer, but there's something to modify for right solution.
Installing .NET 4.0 is right and it's mandatory for working on Windows 10 & 7 x64.
But "Visual C++ Redistributable for Visual Studio 2015" should not be necessary.
Without these packages, the app can executes on windows 7 & 10 x64.
Of course, the app requires some dlls in C++ Redistributable packages. But not all.
So I put dlls the app requires at the same directory of .exe file.
That's all.
There's no other requirements.

Related

How to set the required version of C++ redistributables

I created a dll based off a sample project that is several years old.
I am building the dll and can register this dll successfully on my computer which has both 2010 and 2015-2019 C++ redistributables installed.
When I try to install this same dll on a computer with only 2015-2019 c++ redistributables installed, registration fails. After installing the 2010 c++ redistributables on that machine, the dll installed successfully.
I would like to be able to register this dll on a computer with only the 2015-2019 redistributables installed. I assume this has something to do with the configuration of the project which I'm building in Visual Studio 2019. I've poked through all the properties but nothing stands out. Would appreciate someone pointing me in the right direction!
Update: The sample I am referring to comes with the Windows sdk and can be found here: C:\Users\user\Source\Repos\Windows-classic-samples\Samples\Win7Samples\winui\shell\appshellintegration\RecipeThumbnailProvider
When I opened it up in Visual Studio 2019 it did some kind of update, but doesn't seem to have affected the redistributable it depends on.
This ended up being related to the fact that I'm using JNI and was dependent on jvm.dll. I was using the jvm.dll from Java 8u202. This version of the dll is dependent on the 2010 C++ Redistributables. Starting with Java 8u261 jvm.dll is dependent on the 2017 Redistributables (source).
Dependency Walker is outdated, but this newer tool, Dependencies, worked with my dll.

How to build C++ project in Visual Studio 2015 and Visual Studio 2002 at one time

I need to build my C++ projects in two environments:
Visual Studio 2015 (VS2015) installed on Windows 10 x64
Visual Studio 2002 (VS2002) installed on Windows XP
Now every time I need to trigger to build my projects twice on 2 PC and this way is not sufficient for me.
I do some research before and someone suggest to install multiple compiler in one PC, but the problem is that VS2002 is too old to be installed on Windows 10 x64.
I am looking for any method or software tool that I can trigger the build once then I can build my projects on both VS2015 and VS2002 (e.g. if I can install both VS2015 and VS2002 in one PC, I can write a simple batch file to build my project in both compiler).
EDIT:
This answer is outdated because of clarification that the software is installed on two physically different machines.
If you have both VS .NET 2002 and VS2015 installed then you already have two compilers installed and they will be installed in two different places. You then should just be able to write a batch file to call each version of cl.exe (making sure the paths are absolute) and compile/link/build each project.

C++ app built on Windows 7 (using VS2010 IDE and VS2008 toolset) runs on Windows 7, but not on Win XP

I have a C++ application, which is built on Windows 7 using VS 2010 IDE against VS2008 toolset. I have verified that it depends on msvc*90.dll.
The problem occurs when i move it to XP professional SP3 machine. I have installed the 32-bit vs 2008 redistributable package too.
However, the application fails to run. No error is reported. Nothing is logged into system even viewer as well.
Any hints?
PS: I have seen the following threads already.
Program Built on Win7 won't run on WinXP
How do I compile for windows XP under windows 7 / visual studio 2008
Have you checked the DLL in that Windows XP system with Dependency Walker. This may help you find if you are not missing another dependency or not dealing with side by side execution problems.
This issue is resolved now. The problem was not related to dependencies. Instead, it was some directory not existing in the file system.

Visual Studio 2012 Project targeting Windows XP using MFC

I have recently acquired source code from a VS2005 project that uses the MFC library. Firstly I upgraded the project to VS2012 and I can now successfully build and run the software on Windows 8. Next, I wanted to deploy the software on a Windows XP machine.
I have set the Platform Toolset to build to Windows XP (using the v110_xp option) and I have installed the 'Visual C++ Redistributable for Visual Studio 2012 Update 1' on the target machine. When I run the software, nothing appears to happen. Via some logging functions I can determine that a call to LoadFrame(IDR_MAINFRAME) causes an exception in kernel32.dll. I can't debug any further in to LoadFrame as remote debugging on Windows XP is not available in VS2012.
Any ideas what may be going wrong? Is the Visual C++ Redistributable package the correct version to be installing on the target machine? What should I be trying next?
UPDATE
My project is already set up to use the 7.1 SDK and has minimum required version set to 5.01 in linker options.
If I use InstallShield to generate an installer and include the MFC, CRT and ATL redistributables, the installer works and my program now runs on Windows XP. My understanding of the redistributables is that they simply copy the relevant dll's in to the system32 folder (or equivalent)? Is that correct?
However, if I simply copy the files over, run the vsredist_x86.exe or use Inno Setup to install the software & dll's, my program no longer works.
I believe you have read this blog. In summary, you need to use the 7.1 SDK, and you need to set minimum required version to 5.01 in linker options.
Using the working InstallShield project and the not-working Inno project I was able to determine that the real culprit here was an unregistered msxml4.dll. The error I was receiving gave no real clue to this outcome but I got there eventually...
regsvr32 msxml4.dll

VS 2012 - XP Issues

I installed VS 2012 Professional and the XP update as well. I built my project with v110_xp as the platform toolset on VS 2012. My project's .msi package is installing fine on Win 7 but failing on Win XP SP3. The error reported on XP SP3 is -
"The procedure entry point FlushProcessWriteBuffers could not be
located in the dynamic link library Kernel32.dll".
While the same project built from VS 2005 is installing fine on XP SP3. I am not sure what is going on VS 2012. _WIN32_WINNT is set to 0x0501. Can some one please guide as how to resolve the problem ?
Any help is highly appreciated,
Mahesh.
Yes, the C Runtime has a dependency on FlushProcessWriteBuffers(). The updated version of msvcrt110.dll and libcmtl.lib, the ones you got along with the update, no longer directly link to the function, they use GetProcAddress() to find it and limp along if it is missng. So you should never get this error.
So very high odds that you deployed the wrong version of msvcrt110.dll, an old one instead of the updated one. You can find it back in c:\windows\system32, look at the properties. Mine is version 11.00.51106.1, dated 11/5/2012. A separate installer is available for it here.
The VS2012 runtime that you are installing uses functions that are not present available in XP. See this MS article: Targeting Windows XP with C++ in Visual Studio 2012 which explains more and provides some workarounds.
Update 1 for VS2012 resolve the problem.
But Update 1 isn’t just about new Windows platforms. It also enables you to target Windows XP with native C++ applications in Visual Studio 2012.
If you are building with update 1 and still encountering problems then I suspect that you are installing an out of date runtime. You need to deploy the runtime delivered with update 1.
You can solve this by including the VC11 merge modules from your development machine(program files\common files\merge modules) in your installer. It's easier than having to run the redist exe in your installer.
If you use WIX: merge module addition
I've tested on server 03, xp64 and xp32.