win32 console program side-by-side configuration error - winapi

A VC++ 2008 win32 console application uses some MFC functions, it can run without problem in 'Debug' mode within the VC++ 2008 environment. Also, the debug executable can ran on any computer with full version of visual studio 2008 installed.
But that same debug executable won't run on systems that don't have the visual studio 2008 installed, it gives the following error message:
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
The initial search for this problem leads to MSN recommendation to install the VC++ 2008 x86 redistributable SP1. But this failed to resolve the problem.
Then, the win32 console application is recompiled for 'Release' mode and it gives the following error message:
fatal error C1189:#error: Building MFC application with /MD[d](CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
this error happens in afx.h header.
I tried to actually #define _AFXDLL in preprocessor, but it created new errors about unable to convert MFC type of string to char* etc
I also tried 'Use of MFC' settings: in static library and shared DLL, both create more errors
The thing is, the original program was created in VC++ 6.0 and it used a lot of MFC functions (especially string and CObject), but after recompile in VC++ 2008 in a win32 console app, it somehow can work in debug mode, but can't be stand-alone exe in release mode, which is kinda what I need to have a stand-alone exe that can run on newer windows (7 or 8)
Could anyone help. Thanks.

Yes. Don't build in Debug mode. Build for Release. You can't legally distribute the Debug DLLs. You can build a Release version with Debugging information in it--via PDB files.

This may also happen if your release build has dependencies against some debug libraries, link against non debug ones.

Related

missing dll errors after creating installer for my project in Visual Studio 2010

I have a fairly large project in Visual Studio 2010
I can build the project in both Debug and Release mode, copy the generated exe file along with a custom dll I need for a function in the program to another computer, and the exe file works without any problems
I am trying to make an installer for this project in Visual Studio 2010, following the instructions here: https://www.technical-recipes.com/2011/how-to-create-an-installer-in-microsoft-visual-studio/
I do not get any errors while building the installer, and I get a setup.exe and an msi file as a result, but if I install my program in another computer (not by development machine), when I try to run my program after installation I get a missing api-ms-win-crt-runtime-l1-1-0.dll error
How do I debug this problem? Since I can simply copy my Release or Debug build to the computer and make it work, doesn't it mean all the dll files my program is dependent on already exists in the other computer? And if this already works, why isn't the installer version working? How do I make sure that everything I need for this program is included in the installer?
My project in MFC dialog based and uses one third party library, for which I have both .lib and .dll file available. I need to do this in Visual Studio 2010. My development machine is Windows 10 64 bit Home edition version 1909. The installer I currently create installs my program in Program Files (x86) folder.
Static Linking MFC: It appears this issue was solved by making sure to statically link to MFC libraries. In the VC++ project: enable the setting: "include MFC in a static library". This enables static linking of MFC components, eliminating the dependency on shared dlls.
This is a common "missing runtime error" - there are generic check lists below which include this as one source for application launch problems.
Warning: Generally static linking should be avoided in order to benefit from security updates to shared dll files via other update mechanisms.
Short Version: In Visual Studio Installer Projects, check if the Visual C++ Runtime is available in the Prerequisites list.
See this answer, here is a quick screen shot:
Tools: If your project is large you might want to consider another MSI tool. There are many limitations with Visual Studio Installer Projects.
Merge Modules: There are merge modules to install the Visual Studio C++ Runtime, but it is recommended to use the setup.exe for these reasons.
Visual C/C++ Runtime: You are probably just missing the Visual Studio C/C++ Runtime. It needs to be deployed with your application, it is not on there by default (unless you link statically, in which case it should not be needed). Skim this list quickly for other ideas.
You can download the VC++ redistributables at ("The latest supported Visual C++ downloads"):
https://support.microsoft.com/en-us/kb/2977003
More Information:
More on the Visual C/C++ Runtime
Secondary Links:
Detecting presence of Visual C/C++ runtime on box
Missing Dependencies and check lists
Scan for application dependencies
Installing VC++ Runtime with merge modules

Missing Dependencies with Qt Build on Separate PC

I am building a Qt App but I am having problems when I move the app to another PC. When I run the .exe the it keeps saying it is missing dependencies and once I transfer the missing one another one pops up. I assume that I need to install something on the target pc that contains all of these DLLs.
Some of the missing dependencies so far:
MSVCP140D.dll
vcruntime140d.dll
api-ms-win-core-rtlsupport-l1-2-0.dll
I think that there may be issues with the install of MSVS or MSVC on my build pc as I constantly have to point to things like UCRT manually.
Thanks in advance
Missing Runtime: Those files are obviously part of a runtime that your application needs (Visual C++ Redistributable for Visual Studio 2015 - maybe?), but more than that you seem to have distributed the debug version of your application which will depend on debug versions of runtime dlls (dll name ends with "d" as in MSVCP140D.dll). These are generally only installed on developer PCs, and are not for distribution to client PCs at all.
Release Build: Maybe try to build your application in release mode and try to run that executable on your client systems. The required runtime might already be present on their boxes, just not in debug version.
Static Linking: I suppose you could also try static linking (for the Microsoft runtime: How do I make a fully statically linked .exe with Visual Studio Express 2005?), if that is available to you (I am not up to speed with Qt's handling of this in terms of availability of static linking with different forms of licensing): MSVCP140.dll missing. Just so it is mentioned: thought conceptually the same, static linking is different for Qt (licensing issues?) and the core Microsoft runtimes (see link above). Use a binary dependency checker to investigate how dependencies have changed with new compilation settings.
Remote Debugging: If you need to make a test PC capable of running your application in debug mode (maybe for remote debugging without installing all of Visual Studio): Preparing a Test Machine To Run a Debug Executable.
"Hacky": It seems here is another, "hackier" approach that I would not really recommend: install VC++ Debug Runtime Distributable. For other Visual Studio versions look for the debug_nonredist folder. Debug versions of an application are not redistributable, and debug versions of the Visual C++ library DLLs are not redistributable. Very important.

Missing System.Data.SQLite.dll reported after installation

The desktop software (.Net 4.0, compiled under Visual Studio 2010, target: x86) I'm developing is shipping with System.Data.SQLite (1.0.86 for x86, from system.data.sqlite.org*) for the first time.
On the development machine (And every other machine where the System.Data.SQLite-installer has run), everything works correctly.
On the testing machine however, after installation (a standard MSI setup created with the Visual Studio Installer) launching the application and showing the splash screen, before showing the GUI, the application creates an exception with the error:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SQLite.dll' or one of its dependencies.
The mentioned file itself is found in the application directory (correct version), along with all the other referenced DLLs.
I assume this works on the development machines because of the setup option 'Install images'. I didn't install SQLite in the GAC. The application project is directly referencing the pre-build System.Data.SQLite.dll with local copy set to true.
Are there any dependencies I'm not seeing?
Or is it a missing Microsoft Visual C++ Runtime Library (Not present in the application directory)?
Or a missing SQLite.Interop.DLL (Not present in the application directory)?
How could I fix those?
= The installer I've used: http://system.data.sqlite.org/downloads/1.0.86.0/sqlite-netFx40-setup-bundle-x86-2010-1.0.86.0.exe
Ensure that you have the latest Microsoft Visual C++ 2010 Redistributable Package installed.
http://www.microsoft.com/en-gb/download/details.aspx?id=5555
Why? The sqlite DLL has some unmanaged code embedded in it that is run directly from the assembly at runtime. This manifested for me as a bad image format exception but you never know!

Visual C++ executable and missing MSVCR100d.dll

I know this has been asked in other places and answered, but I'm having issues with MS Visual Studio 2010. I've developed a C++ executable but if I run the Release version on a machine that doesn't have the VC++ runtime library (ie, msvcr100d.dll), I get the "program cannot start because msvcr100d.dll is missing from your computer" error.
This is weird for two reasons:
Why is it trying to link with the debug version of the redistributable?
I tried applying this fix, setting the runtime library setting to /MT instead of /MD (multi-threaded DLL), but that only made the problem worse (if I manually copied msvcr100d.dll, it then said it couldn't find msvcp110.dll).
How can I package the runtime library with my executable so that I can run it on machines that don't have MS VC 2010 or the redistributable installed?
I know it's considered a security risk to include a copy of the DLL since it won't ever be updated, but my goal is just to send this executable to a few friends in the short term.
You definitely should not need the debug version of the CRT if you're compiling in "release" mode. You can tell they're the debug versions of the DLLs because they end with a d.
More to the point, the debug version is not redistributable, so it's not as simple as "packaging" it with your executable, or zipping up those DLLs.
Check to be sure that you're compiling all components of your application in "release" mode, and that you're linking the correct version of the CRT and any other libraries you use (e.g., MFC, ATL, etc.).
You will, of course, require msvcr100.dll (note the absence of the d suffix) and some others if they are not already installed. Direct your friends to download the Visual C++ 2010 Redistributable (or x64), or include this with your application automatically by building an installer.
For me the problem appeared in this situation:
I installed VS2012 and did not need VS2010 anymore.
I wanted to get my computer clean and also removed the VS2010 runtime executables, thinking that no other program would use it.
Then I wanted to test my DLL by attaching it to a program (let's call it program X).
I got the same error message.
I thought that I did something wrong when compiling the DLL.
However, the real problem was that I attached the DLL to program X, and program X was compiled in VS2010 with debug info. That is why the error was thrown.
I recompiled program X in VS2012, and the error was gone.
This problem explained in MSDN Library and as I understand installing Microsoft's Redistributable Package can help.
But sometimes the following solution can be used (as developer's side solution):
In your Visual Studio, open Project properties -> Configuration properties -> C/C++ -> Code generation
and change option Runtime Library to /MT instead of /MD
Usually the application that misses the .dll indicates what version you need – if one does not work, simply download the Microsoft visual C++ 2010 x86 or x64
from this link:
For 32 bit OS:Here
For 64 bit OS:Here
I got the same error.
I was refering a VS2010 DLL in a VS2012 project.
Just recompiled the DLL on VS2012 and now everything is fine.
Debug version of the vc++ library dlls are NOT meant to be redistributed!
Debug versions of an application are not redistributable, and debug
versions of the Visual C++ library DLLs are not redistributable. You
may deploy debug versions of applications and Visual C++ DLLs only to
your other computers, for the sole purpose of debugging and testing
the applications on a computer that does not have Visual Studio
installed. For more information, see Redistributing Visual C++ Files.
I will provide the link as well : http://msdn.microsoft.com/en-us/library/aa985618.aspx

load c++ dll in ironpython

I have an ironpython app that uses dlls.
Some of the dlls written in c#, and one is in managed c++.
The app works fine on my host, and on any host that includes visual studio (2010) installation.
When I tried to run this app on hosts without vs, It failed. After some checking I discovered that ironpython cannot load the c++ dll.
After installing vs - the app runs fine.
I narrowed it down: the dll can be uploaded after the installation of:
-Microsoft application error reporting
-VC 9.0 Runtime(x86)
-VC 10.0 Runtime(x86)
-Microsoft visual studio macro tools
I tried to install Microsoft Visual C++ 2010 Redistributable Package http://www.microsoft.com/download/en/details.aspx?id=5555 and it didn't do the trick.
Why? what exactly happens in installation of vs, that doesn't occur when I install Microsoft Visual C++ 2010 Redistributable Package component?
How can I monitor errors that arise when loading dlls with ipy?
Thank you!
The DLL that is written in managed C++ uses a DLL for its standard libraries. You can change it to static libraries. Follow these steps
Open your project properties in Visual Studio (right click on the project)
Click you way to Configuration Properties > C++ > Code Generation
On the right, find Runtime Library and select Multi-Threaded Debug (/MTd)
Do the same for the Release build, but this time select Multi-Threaded (/MT)
Rebuild all
As for your specific questions :
1. The redistribuable installer will copy the DLL in the system path. Visual Studio will do the same thing. So if it doesn't work, make shure that you have the 32 or 64 bit binaries (same as your code, not the platform you are running). +If you are running from a console, close it and start a new one to get the updated path.
2. Use Dependency Walker. Loading your DLL will show you what it is looking for, it should be enough. To monitor its runtime execution, load IronPython. In the "Profile" menu, select "Start Profiling" and provide a command line that will reproduce your problem.

Resources