How to resolve conflicting MFC errors?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
The Problem:
"IntelliSense: #Error directive: Please use the /MD switch for _AFXDLL builds" My Google-Fu uncovered reports suggesting the issue was a Visual Studio 2010 bug that could be resolved by switching to use MFC as a Static Library. Unfortunately, as soon as I attempt to use a static library I end up with: "error D8016: /clr and /MTd command-line options are incompatible", which directs me to go back to using MFC as a shared dll instead...
Any ideas on how to resolve these two issues?
Additional Background information:
I am attempting to write a graphical user interface for a usb device logger. My VS10 projcet has the following files: myForm.h, myForm.cpp, Globals.h, resource.h, usbDriver.h, stdafx.h, stdafx.cpp, usbThread.h, usbThread.cpp, usbThread.cpp, AssemblyInfo.cpp, and ApplicationName.cpp. usbDriver.h contains ASCI C access functions for the USB device driver library. usbThread.cpp is set for No Common Language RunTime Support and contains all the unmanaged code. All other .cpp files use (/clr). usbThread.cpp also contains function UINT runTimeThread(LPVOID pParam) called during setup by AfxBeginThread(runTimeThread, NULL); that does the grunt repetitive work of polling and processing the usbDevice activity. Globals.h contains the static variables the user interface needs to control the runTimeThread and is included by usbThread.cpp and myForm.cpp. When MFD is used as a shared DLL ever single variable in Globals.h triggers: "error LNK2005 <variable> already defined in myForm.objFile:usbThread.obj" Ive tried wrapping Globals.h in #ifndef/#define and #pragma once blocks to no avail. I think those errors are part of an error cascade triggered by the previously mentioned intelliSense #error directive, but Im mentioning them anyway in case that happens to be my real problem.

View the full article
 
Back
Top