C++ link issue after switching to /MT - c++

I am working on application which should be running on any Windows NT machine. Today I was trying to deploy my application on new machine and suddenly get error that msvcp100.dll is missing. I've started digging into that problem and found solution. Only what I had to do is in project configurations change Run time library From /MDto Multi-threaded (/MT).
But after switching to current mode I am getting link error. Not sure why and how to fix it. Could you please help me to figure that out? Thanks!

You aren't supposed to deploy debug builds. Compile with Release settings (including release version of the run-time library) and you won't have that problem. (You can enable debug information on a release build... it's use of the debug libraries that causes problems)

The error comes from that when compiling in debug mode, you'll need to change your project to link with link with debug libraries, ie msvcmrtd.lib instead of msvcmrt.lib and msvcrtd.lib instead of msvcrt.lib
Deploying debug binaries to other machines may/will cause runtime problems though since the debug version sof the DLLs aren't (afaik) redistributable, what you probably want to do is to fix your release build.

Related

Having problems registering and using a 64-bit C++ written ATL dynamic library

I am having issues registering and using a dynamic library under Windows 7 x64, the 64-bit version of dll compiles but the compiler log outputs:
Error MSB3073: The command "RegSvr32 /S "...\x64\Debug\xxxxx.dll" exited with code 3.
But, when I build 32-bit version of the dll, compiler log outputs the RegSvr32 command was successful.
I already set the Linker >> General >> Register Output to No in both x86 and x64 build configurations.
I tried running 64-bit and 32-bit version of RegSvr32 (without silent mode) with 64-bit dll, but it responds with the following error:
The module "xxxxx.dll" failed to load. Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files. The specified module could not be found.
I checked it using dependency walker and it reported more than 100 dlls are missing so, I cannot show them here. Some of them are:
API-MS-WIN-CORE-COM-L1-1-1.DLL
API-MS-WIN-CORE-DATETIME-L1-1-1.DLL
API-MS-WIN-CORE-DEBUG-L1-1-1.DLL
API-MS-WIN-CORE-ERRORHANDLING-L1-1-1.DLL
API-MS-WIN-CORE-FILE-L1-2-1.DLL
...
WLANUTIL.DLL
WLDAP32.DLL
WTSAPI32.DLL
XMLLITE.DLL
Dependency Walker with opened dll:
I am wondering what the reason for only 64-bit version of dll cannot register using RegSvr32.
Any help is greatly appreciated to resolve this issue.
UPDATE 1
Trying to running the application with this dynamic library results in the following error (both 32-bit and 64-bit versions) :
The program can't start because api-ms-win-core-errorhandling-l1-1-1.dll is missing from your computer. Try reinstalling the program to fix this problem.
All redistributable packages currently I have installed:
Is there any visual c++ redistributables I have to install to solve this?
UPDATE 2
I found More information on api-ms-win-core-errorhandling-l1-1-1.dll here and tried linking WindowsApp.lib with this dynamic library, but it even didn't resolve the issue.
UPDATE 3
I ran system file checker and it gave me following output as I thought it should:
Windows Resource Protection did not find any integrity violations.
Go into the project properties of the DLL you're trying to register
Go to Configuration Properties >> Debugging
Under "Command", click on the little down arrow and choose "regsvr32.exe"
Under "Command Arguments" type "$(TargetName)"
Put a breakpoint somewhere in your DLLMain
Now Debug the DLL (Right click on the dll project in solution explorer and choose "Debug")
If you get to your DLL main, you can debug from there until it fails. If you do not, you should take a look at the output window to see any relevant messages. You might need to change your output window filters too. Right Click on the output window and check all categories of messages to be sure it gives you everything and then debug again.
That should at least tell you where you are failing. Look for module load failures and the like
Edited to add - you might try just changing the build step by removing the "/S". That is "Silent" mode and in this case you want to see the messages.
I finally solved the problem by removing mincore.lib from linked .lib files in both x86 and x64 versions of project, which I recently linked to use GetFileVersionInfoSize API function.

Why is my application searching the wrong DLL for a function?

I am writing a Qt Application using Visual Studio 2010. My application 'Review.exe' links against QtAV.dll using QtAV.lib. In turn, QtAV links against ffmpeg, portaudio, gdiplus, etc.
The debug version works correctly.
When I try and run the release version I get:
The procedure entry point GdipAlloc could not be located in the dynamic link library avcodec-54.dll.
GdipAlloc is a part of Gdiplus. Why is the wrong dll being searched for the function? This only happens in the release build.
If I replace the release version of QtAV.dll with the debug version of QtAV.dll, the release version of Review will load the debug version of QtAV.dll.
Setting the linker flag /DEBUG on the release build causes the problem to go away. However I'd like to figure out the cause and a proper solution.
I find that it does happens for vs2010. vs2012 works fine. I compile portaudio by vs2010 again(use cmake is quite easy), and generate FFmpeg .lib files by vs2010 tools, then compile QtAV again, this errors disappears!
I have uploaded new development files to build QtAV. Download FFmpeg-2.0.1_mingw32+msvc.7z and portaudio-v19_msvc2010x86_20130813.7z here: https://sourceforge.net/projects/qtav/files/depends
: )

msvcp100.dll is missing - a more informative error

I have a lot of users reporting that they get the "msvcp100.dll is missing" error.
Instead of having users keep reporting this and reply that they need to install the C++ redistributable I would like to change the error text into something more meaningful, e.g. tell them that they need to install C++ redist.
Is this possible?
If you don't want to force users to install the redistributable, you can statically link to the runtime. Go to your Project Settings and find C/C++ >> Code Generation. Change the runtime library setting to multithreaded (/MT) instead of multithreaded dll (/MTd).
I am not sure if it is possible to change the error message. I highly doubt this because it is an error of the loader of the OS.
So why don't you create an installer for your application that will do the checking and if necessary the installation of the redist package?
You can also include in your application's release version the dll's that your application are needed

C++ application fails to start correctly (0xc000000d)

I'm writing a C++ application using VS2010 on two dev computers - both are Win7 64bit SP1. I use git to sync the repositories.
On one of the machines the compiled executable (and also the test exec) stopped working with the following error, while on the other machine it works fine and I'm able to continue development.
The application was unable to start correctly (0xc000000d). Click OK to close the application.
I tried deleting the repository and cloning it again. I also made sure I have the same versions of Boost, git, Visual Studio. Also, I tried debugging (stepping in) but the error occurs before any line of code is reached.
Notice as far as I understand I'm tracking Visual Studio's solution\project configuration files as detailed here.
I'm at a loss, how would you debug this?
UPDATE 1:
Only the Debug version fails to run. The Release version runs fine
UPDATE 2: The executable that doesn't work does work on the other computer!
UPDATE 3: I've reinstalled VS2010 (exactly the same version) - didn't help. Surprisingly the compiled files are not the same size between the two machines.
I got the same problem as you mentioned.
My solution:
Clean the manifest file and rebuild
In the property page-> Manifest tool -> make sure "Additional Options" is set to nothing.
(I set it as "/validate_manifest" before).
Or you can try "Embed Manifest -> NO", rebuild and then set back to Yes. It sounds to be ridiculous, but it really works sometimes. I don't know why.
I got the same phenomenon suddenly without a warning on Win7 / VS2010 / C++. Debug App couldn't be launched, got 0xC000000D at initializing and loading multiple dlls. Found one base dll of my own responsible, played around with linker settings. Modifying settings, incremential rebuild -> app starts, rebuild all -> app crashes again. After setting "generate manifest" to "no" in the linker settings the sample app works, but the main app still crashes. After setting "generate manifest" to "no" for the most of my dlls -> the app starts in debug mode again. The stuff is very spurious, because some dlls need the modified settings others do not.
Have a look at the top two answers to this question
Program crashes with 0xC000000D and no exceptions - how do I debug it?
On the machine where it fails, try running the debug executable NOT under the debugger, and update your question to say what happens. If it crashes, are you able to then attach the debugger whilst the message box is still there and get a stack trace that tells you what function it is crashing in?
This is the weirdest thing....
Try deleting the "ipch" directory and then rebuilding.
Hope it works for you, I have wasted hours on this.
disabling/enabling precompiled headers fixed the issue for me.
I was facing crash on Debug x64 only - I guess it was related to an upgrade from boost 1.50 to 1.52, while keeping pch files.
in my case i got it working again by setting generate manifest to NO on all projects
I have changed "Embed manifest" setting to NO and then back to YES but it didn't help.
For me setting General->Platform Toolset to Windows SDK 7.1 for my program and all dependent libraries compiled with it helped.
It's the ipch just delete the entire folder and it will clear it up. I was confused for a while too.
I saw the error while using OpenCV library compiled with MSVC2010 in a project running on MSVC2015. Changing project configuration properties->General->Platform toolset from Visual Studio 2015(v140) to Visual studio 2010(v100) resolved the error.

how can i diagnose exception in window 7 release mode compilation with VC 2008

i have strange problem , my application (exe) is working fine in debug mode in windows 7
but stop to work with exception when compiling in release mode .
how can i debug the program to find what is causing the exception this is application with more then 300,000 lines of code ..
Compile in Release mode but create the .pdb files: How to generate PDB’s for .net managed projects in release mode?
Deploy the .pdb files to same folder as the .exe.
Then attach to process.
Check the projects settings which are different for debug and release modes, maybe you will find an answer there.
Compile release mode with debug information and turn off optimization. You will have debug version compiled with release defines. If it fails the debugger will show you bad place.
Just turn off optimization. Once upon a time that was an issue for me. In this case it will be really hard to find out the cause.
Create PDBs, it can be done for native C++ too.