L'utilisation afx_msg dans Qt avec msvc2008 compilateur
-
28-10-2019 - |
Question
Je travaille sur un projet Qt avec le compilateur msvc2008, comme le dit le titre.
L'exemple de code, que je suis en train de travailler à l'utilisation de marques afx_maps, et pour autant que je peux dire (je n'ai pas la moindre idée de la façon dont fonctionne AFX), le code ci-dessous signifie que lorsque le message WM_PI_RAWDATA_READY est reçu (je ne sais pas où ni comment il est reçu), la fonction OnRawDataReady est déclenchée.
//{{AFX_MSG_MAP(CPDImfcDlg)
ON_MESSAGE(WM_PI_RAWDATA_READY, OnRawDataReady )
//}}AFX_MSG_MAP
J'ai essayé de copier le code dans mon projet, puis en ajoutant #include dans l'en-tête, mais il me donne l'erreur suivante:
D:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\INCLUDE\afx.h:24: 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]
Les corrections que j'ai trouvé ailleurs pour cela semblent être les paramètres du projet dans Visual Studio, donc je ne suis pas sûr de savoir comment contourner.
Toutes les idées sur la façon de résoudre ce problème, ou comment contourner les choses de afx_msg?
Merci beaucoup
La solution
What about just doing what the error message said and #define
ing the _AFXDLL
preprocessor symbol. Depending on your build environtment you just need to add it to the complier command line as an argument (/D_AFXDLL
, if I remember correctly). But when you're working with Qt you probably got a *.pro file anyway and can just add it there (using the DEFINES
variable). So just add this line to you *.pro file
DEFINES += _AFXDLL
But just integrating MFC code into a Qt application (which are two completely different GUI and OS abstraction libraries) won't be of too much help, as they both won't work together that good, not to speak of the design issue. Perhaps you can port the application from MFC to Qt.
Autres conseils
It basically says that you have to either use static libraries or DLLs. You cannot mix.
Like you say, this is part of the project settings.