Discussion:
MFC and boost::thread
(too old to reply)
Frank
2015-02-18 15:05:03 UTC
Permalink
Dear people,

one cannot use both MFC and boost::thread in one
DLL; the DLL ASSERTs already when loading.

Now, is it possible to get rid of MFC calls
in a (small) DLL? I made it with the wizard
and the "Regular DLL using shared MFC DLL"
option. I switched the compiler options
to "Win32" but was told that if I compile
with the /MD option (for multitasking)
this option creates conflicts.
Geoff
2015-02-18 16:32:31 UTC
Permalink
Post by Frank
Dear people,
one cannot use both MFC and boost::thread in one
DLL; the DLL ASSERTs already when loading.
Now, is it possible to get rid of MFC calls
in a (small) DLL? I made it with the wizard
and the "Regular DLL using shared MFC DLL"
option. I switched the compiler options
to "Win32" but was told that if I compile
with the /MD option (for multitasking)
this option creates conflicts.
What is the exact warning or error message you get?
Lothar Frings
2015-02-19 07:48:28 UTC
Permalink
Post by Geoff
Post by Frank
Dear people,
one cannot use both MFC and boost::thread in one
DLL; the DLL ASSERTs already when loading.
Now, is it possible to get rid of MFC calls
in a (small) DLL? I made it with the wizard
and the "Regular DLL using shared MFC DLL"
option. I switched the compiler options
to "Win32" but was told that if I compile
with the /MD option (for multitasking)
this option creates conflicts.
What is the exact warning or error message you get?
fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

if I switch on Configuration Properties -> General -> Use of MFC
from "Use MFC in a Shared DLL" to "Use Standard Windows Libraries".
Geoff
2015-02-19 17:15:30 UTC
Permalink
On Wed, 18 Feb 2015 23:48:28 -0800 (PST), Lothar Frings
Post by Lothar Frings
Post by Geoff
Post by Frank
Dear people,
one cannot use both MFC and boost::thread in one
DLL; the DLL ASSERTs already when loading.
Now, is it possible to get rid of MFC calls
in a (small) DLL? I made it with the wizard
and the "Regular DLL using shared MFC DLL"
option. I switched the compiler options
to "Win32" but was told that if I compile
with the /MD option (for multitasking)
this option creates conflicts.
What is the exact warning or error message you get?
fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
if I switch on Configuration Properties -> General -> Use of MFC
from "Use MFC in a Shared DLL" to "Use Standard Windows Libraries".
This is an #error directive from the Microsoft source code,
specifically the <afx.h> header which is included by <afxwin.h> which
is included in your "stdafx.h" header in your project due to the
wizard creating the project for you when you first chose to create the
project and now those headers don't like your build settings.

You might be able to straighten it out by removing everything after
#include "targetver.h" in your "stdafx.h" file and including
<windows.h> and refactoring your other project files.

The Win32 project version of stdafx.h looks something like this:
__________________________________________________________
#pragma once

#include "targetver.h"

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff
// Windows Header Files:
#include <windows.h>
__________________________________________________________

The problem with tweaking by hand in order to undo the wizards is that
you never catch everything in the first round and you end up tweaking,
rebuilding, tracking down the errors, tweaking, rebuilding, fixing the
link errors, etc, all very time consuming. Then you have to fix the
release side of the project once you have the debug side more or less
successfully building.

If your project is going to use boost and not MFC then at this point
you should probably abandon trying to tweak the project by hand and
just create a new project as a Win32 DLL. Back up your existing
project and set it aside, create your new project and add it to your
existing solution if it's part of a larger solution, copy-paste your
application code (if any) out of the existing project and into the new
one.

In my experience the time needed to "fix" an improperly configured
wizard-created project by hand is far greater than the time needed to
create a new project with the wizard, paste-in my application code and
resume from there. The wizards are designed to save time but when you
choose wrongly, it's best, IMHO, to wipe the slate clean and start
over.

Loading...