benny_czarny
asked on
MFC extension DLL calling STL
Hi all
I am Trying to create an MFC extension DLL calling an STL : list
which will not take MSVCR*.DLL as on of it's dependants
Can I do that ?
If yes Then How ?
I am Trying to create an MFC extension DLL calling an STL : list
which will not take MSVCR*.DLL as on of it's dependants
Can I do that ?
If yes Then How ?
ASKER
// STL
#include <list>
using namespace std;
Yes but when I do that in an MFC extention DLL I immediately get
MSVC*.dll linked to this DLL
How can I avoid that
Thanks
Benny
#include <list>
using namespace std;
Yes but when I do that in an MFC extention DLL I immediately get
MSVC*.dll linked to this DLL
How can I avoid that
Thanks
Benny
>>How can I avoid that
Simple answer: Do not use MFC or link the MFC libs statically...
Simple answer: Do not use MFC or link the MFC libs statically...
BTW: You don't have to reject answers if you need some clarification...
ASKER
sorry about that i'll find a way to deliver points
But still I want to use MFC dinamically and use the Stl as I said
thank
Benny
But still I want to use MFC dinamically and use the Stl as I said
thank
Benny
ASKER
Adjusted points to 140
Ooops, sorry, now I understand your problem ;-)
STL needs the C runtime (CRT) which is contained in this DLL(s). To overcome this, go to the Project Settings, choose the 'C++' tab, select 'Code Generation' from the combo box and change 'Use run-time library' to the appropriate setting (single/multi-threaded, eventually debug, depending on debug/relese) that does NOT use the DLL (or specify /ML(d) in the makefile), so the DLL will be linked to 'libc(m)(d).lib'
STL needs the C runtime (CRT) which is contained in this DLL(s). To overcome this, go to the Project Settings, choose the 'C++' tab, select 'Code Generation' from the combo box and change 'Use run-time library' to the appropriate setting (single/multi-threaded, eventually debug, depending on debug/relese) that does NOT use the DLL (or specify /ML(d) in the makefile), so the DLL will be linked to 'libc(m)(d).lib'
ASKER
Thanks
Yes I've tried all of the 'Code Generation' options - (I am using a multithreaded dll )
But still MSVC*.dll are depenents
( I cannot use MTd option I get
#error : Please use the /MD switch for _AFXDLL builds
because my of my AFXDLL usage
)
Yes I've tried all of the 'Code Generation' options - (I am using a multithreaded dll )
But still MSVC*.dll are depenents
( I cannot use MTd option I get
#error : Please use the /MD switch for _AFXDLL builds
because my of my AFXDLL usage
)
Hmm, it seems that MFC insists on using the DLL version of the C runtime (which usually isn't too bad either) - as an MFC extension DLL (I don't use them too often) requires using this particular DLL anyway, why do you want to get rid of it?
BUT: What about placing the STL code in a separate (Win32) DLL that is used by your extension DLL?
ASKER
Thanks for the workaround
But still we cannot separate this dll
Benny
But still we cannot separate this dll
Benny
ASKER
Adjusted points to 180
ASKER
Adjusted points to 280
ASKER
Why do you want to get rid of it ?
Well I do not want the MSVCr*.dll depedency
Benny
Well I do not want the MSVCr*.dll depedency
Benny
What about using a 'regular' MFC DLL instead of an extension DLL? According to the header files (afxver_.h), an #error directive is issued when you try to get rid of this DLL...
ASKER
Thanks again but I have to export function in this dll
The problem seems to be that the compiler always Produce an import library for applications using the DLL to link with.
The problem seems to be that the compiler always Produce an import library for applications using the DLL to link with.
>> but I have to export function in this dll
That's also possible from a regular MFC DLL. The import library doesn't matter at all...
That's also possible from a regular MFC DLL. The import library doesn't matter at all...
ASKER
Thanks
Yep But I export extended" derive classes from this dll
Yep But I export extended" derive classes from this dll
Hmm, don't be bothered, but I fear you have to get used to the idea of using msvcrt.dll ;-)
ASKER
Thanks
But stil why
But stil why
MFC extension DLLs rely on the dynamically linked version of the CRT:
(see afxver_.h)
////////////////////////// ////////// ////////// ////////// ////////// ////////// /
// For target version (one of)
// _CUSTOM : for custom configurations (causes afxv_cfg.h to be included)
//
// Additional build options:
// _DEBUG debug versions (full diagnostics)
// _AFXDLL use shared MFC DLL
// _AFXEXT extension DLL version, implies _AFXDLL
// _USRDLL create regular DLL (_AFXDLL is valid too)
//
#ifndef _DEBUG
#define _AFX_ENABLE_INLINES
#endif
#define _AFX_NO_NESTED_DERIVATION
////////////////////////// ////////// ////////// ////////// ////////// ////////// /
// Special configurations
// _AFXEXT implies _AFXDLL
#if defined(_AFXEXT) && !defined(_AFXDLL)
#define _AFXDLL
#endif
#if defined(_AFXDLL) && !defined(_DLL)
#error Please use the /MD switch for _AFXDLL builds
#endif
#ifndef _MAC
#if defined(_AFXDLL) && !defined(_MT)
#error Please use the /MD switch (multithreaded DLL C-runtime)
#endif
#endif
This means, when a configuration different from /MT is specified, the #error directive is emitted causing the compilation to abort (specifying /MT on the command line causes the compiler to internally '#define _MT'). So , you're out of luck, as this header will not compile when you're not using 'multithreaded DLL' (I would _not_ advise to #define _MT manually - who knows about the ramifications of the MFC codebase - but this would be the last resort...)
(see afxver_.h)
//////////////////////////
// For target version (one of)
// _CUSTOM : for custom configurations (causes afxv_cfg.h to be included)
//
// Additional build options:
// _DEBUG debug versions (full diagnostics)
// _AFXDLL use shared MFC DLL
// _AFXEXT extension DLL version, implies _AFXDLL
// _USRDLL create regular DLL (_AFXDLL is valid too)
//
#ifndef _DEBUG
#define _AFX_ENABLE_INLINES
#endif
#define _AFX_NO_NESTED_DERIVATION
//////////////////////////
// Special configurations
// _AFXEXT implies _AFXDLL
#if defined(_AFXEXT) && !defined(_AFXDLL)
#define _AFXDLL
#endif
#if defined(_AFXDLL) && !defined(_DLL)
#error Please use the /MD switch for _AFXDLL builds
#endif
#ifndef _MAC
#if defined(_AFXDLL) && !defined(_MT)
#error Please use the /MD switch (multithreaded DLL C-runtime)
#endif
#endif
This means, when a configuration different from /MT is specified, the #error directive is emitted causing the compilation to abort (specifying /MT on the command line causes the compiler to internally '#define _MT'). So , you're out of luck, as this header will not compile when you're not using 'multithreaded DLL' (I would _not_ advise to #define _MT manually - who knows about the ramifications of the MFC codebase - but this would be the last resort...)
ASKER
Thanks
How can I deliver you the points ?
How can I deliver you the points ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Simply include 'lit' and make sure that you're using the correct namespace:
// STL
#include <list>
using namespace std;
Feel free to ask if you encounter any problems!