// JP opened flex table

Click to See Complete Forum and Search --> : Exe And Dll, Debug Mode And Release Mode


Yong-Kyu Kim
July 17th, 1998, 11:06 PM
I have an Exe and a DLL(MFC Extension).


When my exe APP was built Debug Mode, My Dll must be Debug mode.


When my exe APP was built Release Mode, My Dll must be Release mode.


if exe App is Release Mode and Dll is Debug Mode, Error.


if exe App is Debug Mode and Dll is Release Mode, Error.


Please, tell me why error


I'm sorry for unfamiliar English.


Thanks.

Petr Novotny
July 20th, 1998, 04:29 AM
Hi,


I guess both your app and dll use a shared MFC dll. That's the reason - they both have to use the same copy of the dll since MFC stores a lot of private data...


Petr

William Bonnet
November 8th, 1998, 11:53 AM
Looks like you have a problem with memory allocation.


When an application is built in debug mode it does not allocate memory from the same heap as it does in release mode.


(have a look to the definition of new and delete operator, and also to malloc (in afxmem.h ? (not sure just grep it))


Thus, when you get some memory from your debug app and give this memory to your release dll for processing and FREEING, you get an error since the realase dll tries to free it from the wrong heap.


So always use your app and dll in the same mode.

At least, do not try to free memory allocation in one mode in the other mode.

Michel Wassink
June 1st, 1999, 10:45 AM
Create something like this in your dll
#ifdef BUILD_NSVIEWS
#define AFX_EXT_NSVIEWS AFX_CLASS_EXPORT
#else
#define AFX_EXT_NSVIEWS AFX_CLASS_IMPORT
#endif


#ifndef BUILD_NSVIEWS
#if defined (_DEBUG)
#pragma comment(lib,"NSViews_d.lib")
#pragma message("Automatically linking with NSViews_d.dll")
#else
#pragma comment(lib,"NSViews_r.lib")
#pragma message("Automatically linking with NSViews_r.dll")
#endif
#endif

and place a ';' before LIBRARY in your def file.
; NSViews.def : Declares the module parameters for the DLL.

;LIBRARY "NSVIEWS"
DESCRIPTION 'NSVIEWS Windows Dynamic Link Libr

and change output names in your project settings for different builds.

Kirk Stowell uses similar for CJ60 lib.

Good luck

,,,^..^,,,
Michel

//JP added flex table