Building BCI2000 3.0 in MSVC 2005

Forum for software developers to discuss BCI2000 software development
Locked
tmile77
Posts: 8
Joined: 18 Jan 2010, 09:21

Building BCI2000 3.0 in MSVC 2005

Post by tmile77 » 19 Feb 2010, 12:32

After some difficulties Joerg Fisher and me managed to build BCI2000 v3.0 release version in Visual Studio 2005. Since there were several persons looking for advices how to do this, we wanted to share our experiences.

To build you have to:

1. Download the source code and create a visual studio 2005 solution using cmake. To do this run

Code: Select all

cmake -G"Visual Studio 8 2005"
in the ..\build directory using the command prompt or make a .bat script similar to ones provided with the source files in the build directory. This step is well described in http://www.bci2000.org/wiki/index.php/P ... ild_System and http://www.bci2000.org/wiki/index.php/T ... ild_System. Be aware that you don't need to build the Qt any more to build the BCI2000 since Qt libraries are provided with the source code.

2. Open the solution in Visual Studio 2005

3. There is a compiler error that is present if you try to compile for the older versions of windows errors in the file KeyLogger.cpp regarding macros MSLLHOOKSTRUCT, KBDLLHOOKSTRUCT, WH_KEYBOARD_LL, WH_MOUSE_LL, etc. Add _WIN32_WINNT=0x0500 to the preprocessor deffinitions as described here:
http://www.yelsew.com/c2065_wh_keyboard_ll.html
You have to add this deffinition for every project in the solution (or at least the ones that produce errors).
4. There is also a compiler error complaining about the CompareByZOrder operator deffinition in GraphObject.h. On http://www.microsoft.com/communities/ne ... &sloc=&p=1 we read that this error is not present in the debug version. We used the advice from http://www.eggheadcafe.com/aspnet_answe ... 299561.asp to make the operator constant changing the CompareByZOrder definition from:

Code: Select all

struct CompareByZOrder
  { bool operator()( const GraphObject* s1, const GraphObject* s2 )
    { return ( s1->mZOrder == s2->mZOrder ) ? s1 > s2 : s1->mZOrder > s2->mZOrder; }
  };
to:

Code: Select all

struct CompareByZOrder
  { bool operator()( const GraphObject* s1, const GraphObject* s2 ) const
    { return ( s1->mZOrder == s2->mZOrder ) ? s1 > s2 : s1->mZOrder > s2->mZOrder; }
  };
4. Build the solution.

Hopefully this will work for you as well as it worked for us.


We weren't able to build the debug version sine there were some problems with the Qt debug libraries. I will let you know as soon as this problem is solved.

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 19 Feb 2010, 13:31

Thanks for sharing your solution!

Please note that BCI2000 v3.0 has not been released yet, so it is still to be considered in a beta stage.

Best regards,
Juergen

jawilson
Posts: 109
Joined: 28 Feb 2005, 16:31

Post by jawilson » 20 Feb 2010, 14:40

It may also help to know about the free version of visual c++ 2008 that is available from microsoft. It is available here:
http://www.microsoft.com/express/Downlo ... Visual-CPP

and works perfectly!
Adam

tmile77
Posts: 8
Joined: 18 Jan 2010, 09:21

Post by tmile77 » 22 Feb 2010, 13:16

We finally succeded in building the debug version. I'm not sure this is the easiest way since we might have overlooked something, but here it goes:

Repeat the first three steps from the release version instructions (top of the page)

4. At this point we couldn't build since we had some problems with the QT debug libraries provided with the BCI2000 v3.0. So we decided to build our own QT. So we downloaded the newest version (http://qt.nokia.com/downloads) of the SDK, which was 4.6.1 at the time. We had a lot of problms trying to build the whole qt, and we gave up in the end, but we managed to build the libraries important for the BCI2000 which are:

Code: Select all

QtCored4.lib
QtGuid4.lib
QtOpenGld4.lib
To do this configure with:

Code: Select all

configure -shared -debug -platform win32-msvc2005
go to the directories that have the names of the needed libraries and run nmake.
Than go to the Visual Studio and exchange all include paths pointing to the qt provided by BCI2000 to the corresponding include paths pointing to yours qt include paths in the properties of every project in the solution (Configuration properties -> C/C++ -> General -> Additional Include directories). For us this meant changing

Code: Select all

 E:\BCI 2000 v3.0\src\extlib\qt\include into C:\Qt\2010.01\qt\include

Code: Select all

 E:\BCI 2000 v3.0\src\extlib\qt\include\QtGui into C:\Qt\2010.01\qt\include\QtGui

Code: Select all

 E:\BCI 2000 v3.0\src\extlib\qt\include\QtCore into C:\Qt\2010.01\qt\include\QtCore

Code: Select all

 E:\BCI 2000 v3.0\src\extlib\qt\include\QtOpenGL into C:\Qt\2010.01\qt\include\QtOpenGL
In adition you have to change the libraries you link against from the ones provided by the BCI2000 to the ones you built in the properties of every project in the solution (Configuration properties -> Linker -> Input -> Additional Dependencies). For us this meant changing:

Code: Select all

"E:\BCI 2000 v3.0\src\extlib\qt\msvc\lib\QtGuid.lib" into "C:\Qt\2010.01\qt\lib\QtGuid4.lib"

Code: Select all

"E:\BCI 2000 v3.0\src\extlib\qt\msvc\lib\QtCored.lib" into "C:\Qt\2010.01\qt\lib\QtCored4.lib"

Code: Select all

"E:\BCI 2000 v3.0\src\extlib\qt\msvc\lib\QtOpenGLd4.lib" into "C:\Qt\2010.01\qt\lib\QtOpenGld4.lib"
For the end, you have to exchange the moc.exe belonging to the qt provided with the BCI2000 to the one belonging to the one you built. For us this meant copying

Code: Select all

C:\Qt\2010.01\qt\bin\moc.exe
over

Code: Select all

E:\BCI 2000 v3.0\src\extlib\qt\mingw\bin\moc.exe
E:\BCI 2000 v3.0\src\extlib\qt\msvc\bin\moc.exe
5. Build the solution

I'm quite sure there is an easier way to do all this, but this worked for us. I'm not sure why the provided qt libraries are not working. I checked this second the qt lib directory in the BCI2000 files and there are QtCored4.lib and QtGuid4.lib libraries, so maybe just changing:

Code: Select all

"E:\BCI 2000 v3.0\src\extlib\qt\msvc\lib\QtGuid.lib" into "E:\BCI 2000 v3.0\src\extlib\qt\msvc\lib\QtGuid4.lib"

Code: Select all

"E:\BCI 2000 v3.0\src\extlib\qt\msvc\lib\QtCored.lib" into "E:\BCI 2000 v3.0\src\extlib\qt\msvc\lib\QtCored4.lib"
would do the trick. If someone can test this, I would be grateful.


It might also be the case that step number 3 is not necessary, but I'm quite sure release version is not going to compile without it, so it's beter to do it at the start, than later when you try to implement yur new code and compile as release.

griffin.milsap
Posts: 58
Joined: 08 Jun 2009, 12:42

Post by griffin.milsap » 26 Feb 2010, 14:26

Thanks for posting your solution to making BCI2000 work in VS2005. I'm sure others will have the same problem, and this should help them out.

When I originally put together the new BCI2000 build system, I had required that all users go and download the Qt sdk and compile it for their platform manually. This resulted in a 2 hour build and a huge headache for the end user. Although doing this would mean that all compilers are supported equally, it was such a pain in the neck compared to how BCI2000 used to be built.

The decision to include Qt in the distribution - although at first I was not entirely happy with - is actually quite a boon to the developer. If we include pre-compiled Qt libraries that are compiled with the most used compiler, we can optimize the build process for the majority of the users. Unfortunately, if you use a compiler which does not work with the included, pre-compiled Qt libraries, you'll have to manually compile Qt for your platform and point your compiler at the new Qt libraries as described above.

That said, is it safe to assume that the included libs have been compiled for VS2008? Perhaps we should include libs for all the supported compilers. I can help out with compiling on all the different platforms.

-Griff

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 01 Mar 2010, 08:26

For linking BCI2000 against a Qt version outside the BCI2000 source tree, there is an easier way than copying libraries:
In BCI2000/build/cmake/FindQt.cmake, line 10, replace

Code: Select all

SET( USE_STD_QT FALSE )
with

Code: Select all

SET( USE_STD_QT TRUE )
Then, the build system will use the standard rules for finding a Qt installation, i.e. it will use the one with qmake installed in the system search path.

--Juergen

tmile77
Posts: 8
Joined: 18 Jan 2010, 09:21

Post by tmile77 » 15 Mar 2010, 17:42

I would like to confirm that mellinger's suggestion works. In addition you can make your life easy by adding

Code: Select all

IF( WIN32 )
ADD_DEFINITIONS( -D_WIN32_WINNT=0x0500 )
ENDIF( WIN32 )
to the top (line 13 in my case) of the CMakeList.txt in the %BCI2000_DIR%\build folder instead of adding _WIN32_WINNT by hand (point 3). I guess it's more correct to add

Code: Select all

IF( MSVC)
ADD_DEFINITIONS( -D_WIN32_WINNT=0x0500 )
ENDIF( MSVC)
instead, but I didn't test this.

Apart from building Qt, this makes building BCI2000 in MSVC 2005 quite easy.

Locked

Who is online

Users browsing this forum: No registered users and 0 guests