visual studio change dynamic linking to static linking for win32 app - visual-studio-2010

the app is already created with dynamic configuration
anybody knows how to change dynamic linking to static linking for win32 app ?
Note: just changing
Properties -> Configuration Properties -> C/C++ -> Code Generation
gives an linking error
thanks for all help

On the Properties -> Configuration Properties -> C/C++ -> Code Generation
Setting 'Runtime Library' from Multi-threaded (/MT) to Multi-threaded Debug (/MTd) worked for me so the msvcr100.dll was no longer required because it is built into the exe. Thus static linking is enabled.
I did not get any linking error. What is the error you got?

Related

How to load OpenCV's PDB debug files for debugging OpenCV source codes

I compiled OpenCV and I have PDB file for both debug and release mode.
I can program and run OpenCV's APIs, but I can't debug into OpenCV's source files using F11.
I need to link to those pdb files. I did the followings, but still have the problems.
(1)Tools > Options > Debugging > Symbols > Check Microsoft Symbols Server
(2)In the same dialog, at Cache symbols in this directory, I link to D:\OpenCV_Lib_2.4.6\Win64\bin\Debug, where pdb files are there.
(3)Set D:\OpenCV_Lib_2.4.6\Win64\bin\Debug and D:\OpenCV_Lib_2.4.6\Win64\bin\Release to Environment Path.
What else I still need to do to have debugging into OpenCV's sources.
I use Visual Studio 2010.
Thanks
I solved the problem. The first step, all library files must have their pdb files in the same folder where library files are located. Secondly, in the VC++ project setting Configuration properties -> C/C++ -> optimization -> Disable. If it is selected for maximize speed, will have problem. Finally, Configuration properties -> Linker -> Debugging -> Generate debug info -> YES. Then problem is solved.

Debugging in release mode or changing _iterator_debug_level?

I am working with a checked-out Visual Studio C++ Project originally built in VS 2006. I want to put in breakpoints to see where certain functions are called and better follow the workflow.
I rebuilt the code in Visual Studio 2010 in Release mode, and it builds and runs well. Unfortunately, from some research, I have learned that some of the breakpoints cannot be hit in Release mode and I need to build the code in Debug mode to hit the breakpoints.
However, when I try to build the code in Debug mode, the linker complains about the .lib files having the wrong _ITERATOR_DEBUG_LEVEL. Is there a way that I can change this _ITERATOR_DEBUG_LEVEL in the .libs so I can build it in debug mode? If not, is there any way to hit these breakpoints in Release mode or ReleaseWithDebug mode?
I just saw this article from Hansleman recently:
http://www.hanselman.com/blog/DebugVsReleaseTheBestOfBothWorlds.aspx
It basically says you can compile for optimizations (Release) and debug without recompile (Debug) using a combination of debug settings and an ini file.
You can debug C++ in release mode by configuring the projects Properties Pages as follows:
Under C/C++ node -> General node.
Set "Debug Information Format" to "C7 compatible (/Z7)" or "Program
Database (/Zi)".
Under Linker node -> General node. Set "Enable Incremental Linking" to "No (/INCREMENTAL:NO)".
Under the Linker node -> Debugging node. Set "Generate Debug Info" to "Yes (/DEBUG)".
Under Linker node -> Optimization node. Set "References" to "/OPT:REF"
Under Linker node -> Optimization node. Set "Enable COMDAT Folding" to "/OPT:ICF".
You can now debug and step through the code in your release build application.
Note: When setting the properties make sure you have selected the correct configuration and platform (the combo-boxes at the top of the properties pages)

main vs. wWinMain

Summary: I'm trying to compile a NVIDIA SDK app in Visual Studio 2012 on Windows 8 and I get the error message: FXC : error X3501: 'main': entrypoint not found. I'm new to Windows programming and trying to figure out what this means.
Details:
I'm trying to compile the Multi-View Soft Shadows NVIDIA SDK app. After downloading it I had a vcproj file. I opened this in Visual Studio 2012 on Windows 8 and had some warnings during the conversion but it seemed to open the project correctly.
However, when I build the project I get the following error: FXC : error X3501: 'main': entrypoint not found.
At first I thought this might be because there is no main function in the application. But then I found the wWinMain which I guess is supposed to replace main in some Windows applications. So I think that the source code is correct, but perhaps there is some setting with Visual Studio 2012 that needs to be changed. But searching for that error message hasn't answered my question, so I'm wondering if someone can explain what the cause of the error is and any advice about how I could fix it.
This isn't a C++ problem... the shader compiler, fxc.exe, is looking in your shader code for a function called main. It isn't finding it and throws an error as a result. Right click on your HLSL files and go to Properties -> Configuration Properties -> General. There should be an Item Type field. Change it from HLSL Compiler to Does not participate in build. That should prevent the HLSL compiler from coming along and giving you those errors.
You need to change (in Project Properties -> Linker -> System -> SubSystem) the subsystem of your application from CONSOLE to WINDOWS. After that, the entry point will be changed from Standard C/C++ main to Windows-specific wWinMain.

Missing msvcr100.dll

I made a program in Visual Studio 2010 on Windows 7 64-bit.
When I try to run it on Windows XP 32-bit I got message that msvcr100.dll is missing. When I try to copy that file from Win7 to WInXP I got message that msvcr100.dll is wrong.
How to set building in VS so msvcr100.dll would not be necessary?
First you need to make sure you're building a 32 bit executable - 64 bit ones won't run on 32 bit Windows.
Then you can either...
Ship the 32 bit redistributables with your application.
Remove the runtime dependency altogether and link statically to the C++ runtimes. To do this, set Project -> Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library to Multi-threaded (/MT).
Linking the runtime libraries statically should help. Go to Project Options -> C/C++ -> Code Generation -> Runtime Library and change the value to Multithreaded or Multithreaded Debug and recompile. This way your application shouldn't depend on the runtime DLLs.
Also don't forget to build a 32bit executable.
The answers above helped me along, but I was still getting the error:
fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds
So to help other who may have, like me, spent way too much time stumbling around in search of a clear solution, I'd like to add the bit of information that solved this issue for me. As it turns out, my project had the wrong "Use of MFC" setting to make use of the answer above.
To put it in clear terms:
Open up the project properties (alt-F7 or Project-menu -> [My Project] Properties) and go to Project -> Properties -> Configuration Properties
If General -> Use of MFC is set to Use MFC in a Static Library
you must set
C/C++ -> Code Generation -> Runtime Library
to either Multi-threaded Debug (/MTd) or Multi-threaded (/MT)
and if
General -> Use of MFC is set to Use MFC in a Shared DLL
you must set
C/C++ -> Code Generation -> Runtime Library
to either Multi-threaded DLL (/MD) or Multi-threaded Debug DLL
I got this answer from the Microsoft community answers website and all credit should go to David Wilkinson.
The keyword here is "redistributable" since this error message may occur when attempting to run a .exe that was not developed on the end-user's PC.
The following is a good (and trusted) source to download redistributables without having to download the entire VC++ package or patch:
https://visualstudio.microsoft.com/vs/older-downloads/#microsoft-build-tools-2015-update-3
In my case I needed the "Visual Studio 2010 VC++ Redistributable" even though we are in year 2022.
enter image description here
Step 1.: Go to this website dll-files.com.
enter image description here
dll-files.com is a great repository of Windows DLL files and has almost all the DLL files that are existent on Windows.
Step 2. Now type there your DLL error in the search window of the website.
Step 3. DLL-Files.com will immediately list out the zip file containing that particular DLL file. Download this zip file to your computer and extract it. The extracted folder will contain the DLL error file.
enter image description here
Step 4. Copy the download DLL file (Only that file) and paste this file in your default system folder based on your operating systems below.
C:WindowsSystem (Windows 95/98/Me)
C:WINNT\System32 (Windows NT/2000)
C:\Windows\System32 (Windows XP, Vista, Windows 7/Windows 8.1/Windows 10)
Windows will ask you whether you want to replace the existing DLL file with the new one. Say yes and let Windows copy the file. Restart your computer and voila, you can now run the game/app that was not opening and giving the DLL error, easily.
There are many other websites which will give you DLL files that you want

Visual Studio cannot find CPPUNIT debugging database

I am using Visual Studio 2008 with CPPUNIT. I already compiled CPPUNIT and added the CPPUNIT path to Include and Library path. Currently, I can compile my program with CPPUNIT library.
However, the linker generates the following warning:
Warning 2 warning LNK4099: PDB 'vc90.pdb' was not found with
'C:\Program Files\cppunit\cppunit-1.12.1\lib\cppunitd.lib' or at
'c:\Users\hide1713\Desktop\3d_tank\cpp_pj\bin\vc90.pdb'; linking
object as if no debug info cppunitd.lib GameUnitTest
There's a cppunitd_dll.pdb file along with cppunitd.lib. How do I tell the linker where to find the CPPUNIT debug database?
Thanks all.
In your CppUnit project, be sure you have your compiler emitting a program database file that's compatible with your main project. In the CppUnit project properties window, under the Config properties / C++ / General tree, you'll see the Debug Information Format box. Select "Program Database /Zi" or whatever value exactly matches the same setting on your main project. You'll then have to recompile them both, of course.

Resources