Reusing MFC libraries in a new driver for OV
Posted: Sun Apr 15, 2012 5:33 pm
Hello there,
I am trying to code a driver (non configurable for now) to connect a low cost unit by Symtop (UE-16A, 16 canaux) to the OpenVibe acquisition server.
I compiled a 1st time all the OV sources (openvibe-0.13.1-svn3210-src with the OS Vista SP1 and VC++ 2010) using the provided scripts to set the environment, to install the dependencies and to build provided in... /scripts.
I then generated a skeleton driver to code mine and put all the stuff in: C:\OpenVibeProj\openvibe-applications\acquisition-server\trunc\src\SymtopProducts
I also generated a project to later work under the visual 2010 IDE.
-I started to code ovasCDriverSymtop and ovasCConfigurationSymtop (.h and .cpp),
-I included EEGAMP.dll, EEGAMP.h in the same folder (and EEGAMP.obj in C:\OpenVibeProj\openvibe-applications\acquisition-server\trunc\lib),
-I modofied ovasCAcquisitionServerGUI.cpp to include:
// include Symtop's CDriver
#include "SymtopProducts/ovasCDriverSymtop.h"
and:
// initializes Symtop's driver class
if(l_bShowUnstable) m_vDriver.push_back(new CDriverSymtop(m_pAcquisitionServer->getDriverContext()));
To include EEGAMP.h (the UE-16A EEG driver's header) in ovasCDriverSymtop.h and ovasCConfigurationSymtop.h , I have to include beforehand the MFC header stdafx.h since EEGAMP.h seems to be a precompiled header (PCH) as said in EEGAMP.h:
//
// EEGAMP.h : main header file for the EEGAMP DLL
//
#if !defined(AFX_EEGAMP_H__10A9D1B8_19AE_41DE_AE91_791C3A9A3FA5__INCLUDED_)
#define AFX_EEGAMP_H__10A9D1B8_19AE_41DE_AE91_791C3A9A3FA5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
(début de EEGAMP.h)
... After the inclusion of stdafx.h in ovasCDriverSymtop.h and ovasCConfigurationSymtop.h,
when I try to build "OpenViBE-acquisition-server-dynamic" (using the Win32build script and a "build order" restricted to "OpenViBE_application_acquisition_server")
I get the following error when the compiler tries to build the ovasCAcquisitionServerGUI.obj (where I included my stuff, see above):
[ 80%] Building CXX object CMakeFiles/OpenViBE-acquisition-server-dynamic.dir/src/ovasCAcquisitionServerGUI.obj
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
ovasCAcquisitionServerGUI.cpp
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afx.h(24) : 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]
I do what the compiler says and I insert in the CMakeLists.txt of the related folder C:\OpenVibeProj\openvibe-applications\acquisition-server\trunc:
# shared MFC dll precompiler directive
SET(CMAKE_MFC_FLAG 2) # use MFC as a shared dll
ADD_DEFINITIONS(-D_AFXDLL) # add the AFXDLL definition
and I try to rebuild... the previous error vanishes but multiple errors related to afxwin.h (included in stdafx.h) appears:
[ 80%] Building CXX object CMakeFiles/OpenViBE-acquisition-server-dynamic.dir/src/ovasCAcquisitionServerGUI.obj
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
ovasCAcquisitionServerGUI.cpp
_WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2208) : error C2146: syntax error : missing ';' before identifier 'm_pConfigs'
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2208) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2208) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2135) : error C2065: 'GID_ZOOM' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2135) : error C2065: 'GC_ZOOM' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2135) : error C2065: 'GC_ZOOM' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2141) : error C2065: 'GID_ROTATE' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2141) : error C2065: 'GC_ROTATE' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2141) : error C2065: 'GC_ROTATE' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2147) : error C2065: 'GID_TWOFINGERTAP' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2147) : error C2065: 'GC_TWOFINGERTAP' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2147) : error C2065: 'GC_TWOFINGERTAP' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2161) : error C2065: 'GID_PAN' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2161) : error C2065: 'GC_PAN' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2161) : error C2065: 'GC_PAN' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2167) : error C2065: 'GID_PAN' : undeclared identifier
etc....
And I cant' get rid of these ! I strongly doubt that these errors really exist as such (afxwin being a pilar of MFC ! not my own code) so where is the flaw ?
Any help really appreciated as I am not a c++ specialist !
Jeff B.
I am trying to code a driver (non configurable for now) to connect a low cost unit by Symtop (UE-16A, 16 canaux) to the OpenVibe acquisition server.
I compiled a 1st time all the OV sources (openvibe-0.13.1-svn3210-src with the OS Vista SP1 and VC++ 2010) using the provided scripts to set the environment, to install the dependencies and to build provided in... /scripts.
I then generated a skeleton driver to code mine and put all the stuff in: C:\OpenVibeProj\openvibe-applications\acquisition-server\trunc\src\SymtopProducts
I also generated a project to later work under the visual 2010 IDE.
-I started to code ovasCDriverSymtop and ovasCConfigurationSymtop (.h and .cpp),
-I included EEGAMP.dll, EEGAMP.h in the same folder (and EEGAMP.obj in C:\OpenVibeProj\openvibe-applications\acquisition-server\trunc\lib),
-I modofied ovasCAcquisitionServerGUI.cpp to include:
// include Symtop's CDriver
#include "SymtopProducts/ovasCDriverSymtop.h"
and:
// initializes Symtop's driver class
if(l_bShowUnstable) m_vDriver.push_back(new CDriverSymtop(m_pAcquisitionServer->getDriverContext()));
To include EEGAMP.h (the UE-16A EEG driver's header) in ovasCDriverSymtop.h and ovasCConfigurationSymtop.h , I have to include beforehand the MFC header stdafx.h since EEGAMP.h seems to be a precompiled header (PCH) as said in EEGAMP.h:
//
// EEGAMP.h : main header file for the EEGAMP DLL
//
#if !defined(AFX_EEGAMP_H__10A9D1B8_19AE_41DE_AE91_791C3A9A3FA5__INCLUDED_)
#define AFX_EEGAMP_H__10A9D1B8_19AE_41DE_AE91_791C3A9A3FA5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
(début de EEGAMP.h)
... After the inclusion of stdafx.h in ovasCDriverSymtop.h and ovasCConfigurationSymtop.h,
when I try to build "OpenViBE-acquisition-server-dynamic" (using the Win32build script and a "build order" restricted to "OpenViBE_application_acquisition_server")
I get the following error when the compiler tries to build the ovasCAcquisitionServerGUI.obj (where I included my stuff, see above):
[ 80%] Building CXX object CMakeFiles/OpenViBE-acquisition-server-dynamic.dir/src/ovasCAcquisitionServerGUI.obj
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
ovasCAcquisitionServerGUI.cpp
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afx.h(24) : 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]
I do what the compiler says and I insert in the CMakeLists.txt of the related folder C:\OpenVibeProj\openvibe-applications\acquisition-server\trunc:
# shared MFC dll precompiler directive
SET(CMAKE_MFC_FLAG 2) # use MFC as a shared dll
ADD_DEFINITIONS(-D_AFXDLL) # add the AFXDLL definition
and I try to rebuild... the previous error vanishes but multiple errors related to afxwin.h (included in stdafx.h) appears:
[ 80%] Building CXX object CMakeFiles/OpenViBE-acquisition-server-dynamic.dir/src/ovasCAcquisitionServerGUI.obj
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
cl : Command line warning D9002 : ignoring unknown option '-mms-bitfields'
ovasCAcquisitionServerGUI.cpp
_WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2208) : error C2146: syntax error : missing ';' before identifier 'm_pConfigs'
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2208) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2208) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2135) : error C2065: 'GID_ZOOM' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2135) : error C2065: 'GC_ZOOM' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2135) : error C2065: 'GC_ZOOM' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2141) : error C2065: 'GID_ROTATE' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2141) : error C2065: 'GC_ROTATE' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2141) : error C2065: 'GC_ROTATE' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2147) : error C2065: 'GID_TWOFINGERTAP' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2147) : error C2065: 'GC_TWOFINGERTAP' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2147) : error C2065: 'GC_TWOFINGERTAP' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2161) : error C2065: 'GID_PAN' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2161) : error C2065: 'GC_PAN' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2161) : error C2065: 'GC_PAN' : undeclared identifier
c:\Program Files\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\afxwin.h(2167) : error C2065: 'GID_PAN' : undeclared identifier
etc....
And I cant' get rid of these ! I strongly doubt that these errors really exist as such (afxwin being a pilar of MFC ! not my own code) so where is the flaw ?
Any help really appreciated as I am not a c++ specialist !
Jeff B.