Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i've got a project i upgraded from .net 2002 to 2010 recently. long story short, when i have a look at it's dependencies with dependency walker, i see that it's referencing mfc100d.dll and msvr100d.dll (as well as msvr100.dll). These references persist despite the fact that i'm creating a release build of the dll. so i didn't notice the problem of course until i tried to distribute it to normal users. an autocad arx file references it, and the arx load attempt will fail miserably until i drop both of these debug files into the same folder as the arx and dll.

First off, I'm not a C++ guru, so be ready for that. in the project properties of the release config, i've set the linker to not generate debug info (made no difference). other than that, i'm really out of ideas for how to get this damn thing to use mfc100.dll and msvr100.dll instead of their debug counterparts.

Any ideas? suggestions? questions? thanks!

2011/08/09
i'll add that this problem relates to my upgrading it to VS 2010. the 2002 version compiles fine and dependency walker shows no debug dlls in use.
Posted
Updated 9-Aug-11 5:41am
v2

ok, thanks everyone for your suggestions. it dawned on me that i did have to add some preprocessor definitions (read it in a post) after i upgraded to 2010 in order for the damn thing to compile. here's what i put in project properties > c/c++ > preprocessor > preprocessor definitions:

WIN32
_WINDOWS
_DEBUG
_USRDLL
WINVER=0x0501
_WIN32_WINNT=0x0501
_WIN32_WINDOWS=0x0501
_WIN32_IE=0x0500

so _DEBUG is defined there, right? Must be, because i removed the _DEBUG line and now dependency walker doesn't show any debug dll usage. So the problem is solved. thanks again for chipping in, gurus.

I didn't see then that i was making a mistake pasting all of someone's proposed solution to a build issue into my own project and just running with it. Anyone take issue with any of the rest of the defines?
 
Share this answer
 
Comments
YvesDaoust 9-Aug-11 12:03pm    
Glad to read that you found it. There are so many ways to screw up a project ;-)
I'd start by looking at the defines for the release build as the following is pretty usual:
C++
#ifdef _DEBUG
#pragma comment(lib,"debug.lib")
#else
#pragma comment(lib,"release.lib")
#endif


In your case this will probably fix your problem as you'll find this
#ifndef _AFXDLL
	#ifndef _UNICODE
		#ifdef _DEBUG
			#pragma comment(lib, "nafxcwd.lib")
		#else
			#pragma comment(lib, "nafxcw.lib")
		#endif
	#else
		#ifdef _DEBUG
			#pragma comment(lib, "uafxcwd.lib")
		#else
			#pragma comment(lib, "uafxcw.lib")
		#endif
	#endif
#else
	#ifndef _UNICODE
		#ifdef _DEBUG
			#pragma comment(lib, "mfc" _MFC_FILENAME_VER "d.lib")
			#pragma comment(lib, "mfcs" _MFC_FILENAME_VER "d.lib")
		#else
			#pragma comment(lib, "mfc" _MFC_FILENAME_VER ".lib")
			#pragma comment(lib, "mfcs" _MFC_FILENAME_VER ".lib")
		#endif
	#else
		#ifdef _DEBUG
			#pragma comment(lib, "mfc" _MFC_FILENAME_VER "ud.lib")
			#pragma comment(lib, "mfcs" _MFC_FILENAME_VER "ud.lib")
		#else
			#pragma comment(lib, "mfc" _MFC_FILENAME_VER "u.lib")
			#pragma comment(lib, "mfcs" _MFC_FILENAME_VER "u.lib")
		#endif
	#endif
#endif

#ifdef _DLL
	#if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
		#pragma comment(lib, "msvcrtd.lib")
	#else
		#pragma comment(lib, "msvcrt.lib")
	#endif
#else
	#if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
		#pragma comment(lib, "libcmtd.lib")
	#else
		#pragma comment(lib, "libcmt.lib")
	#endif
#endif

in afx.h

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Kevin.Efurd 9-Aug-11 11:35am    
preprocessor stuff is where i really show my lack of formal c++ training. i found the section you quoted in afx.h, but i'm not sure what you mean when you say 'look at the defines for the release build'. is that usually in one place, like a resource file?

i searched the entire project for DEBUG and here's all i found:
(project's resource file)
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif

and this one:

(project's main cpp file)
#ifdef _DEBUG
#define new DEBUG_NEW

#endif
Kevin.Efurd 9-Aug-11 11:37am    
ok i checked the project's properties > resources > general, and for preprocessor definitions i've got NODEBUG on the release config, and _DEBUG on debug config, which should be normal i think.
Espen Harlinn 9-Aug-11 12:12pm    
Sounds reasonable. _DEBUG should only be defined for debug builds, and NODEBUG for release builds. Check that the linker section does not reference the libraries in the project settings, it should only know about the directory containing the libraries - #pragma comment(lib,...) embeds information about which library to use in the *.obj files. Do a rebuild all, not just a build.
You might also want to check the project properties.

Under 'Configuration Properties -> C/C++ -> Code Generation' Make sure that your Runtime Library isn't set to use the Debug versions when doing a Release build.
 
Share this answer
 
Comments
Kevin.Efurd 9-Aug-11 11:20am    
runtime library is set to "multi-threaded dll (/md)" in release config
Also have a look at the Command line in the Linker Configuration properties to check if old library files were not added explicitly.
 
Share this answer
 
Comments
Kevin.Efurd 9-Aug-11 11:22am    
everything looked (more or less) normal:

/OUT:"Release\PanelOptimizer.dll" /INCREMENTAL:NO /NOLOGO /DLL "msxml2.lib" /DEF:".\PanelOptimizer.def" /MANIFEST /ManifestFile:"Release\PanelOptimizer.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /PDB:"C:\DEV_WORK\AireCAD2006PV\AireCAD_Source_Code\PanelOptimizer\Release\PanelOptimizer.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /PGD:"C:\DEV_WORK\AireCAD2006PV\AireCAD_Source_Code\PanelOptimizer\Release\PanelOptimizer.pgd" /TLBID:1 /DYNAMICBASE:NO /IMPLIB:"C:\DEV_WORK\AireCAD2006PV\AireCAD_Source_Code\PanelOptimizer\/PanelOptimizer.lib" /MACHINE:X86 /ERRORREPORT:QUEUE
YvesDaoust 9-Aug-11 11:37am    
Indeed.
YvesDaoust 9-Aug-11 11:41am    
Can you list the software components that make up this project ?

Can it be that some of the C++ source files have different configuration properties ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900