Programming Reference:Building Qt for BCI2000 (obsolete)

From BCI2000 Wiki
Jump to navigation Jump to search

This document describes how to build Qt for installation in the BCI2000 source tree.

Note: Following this procedure is only required if you are a member of the BCI2000 team, and if your task is to update the Qt build coming with BCI2000. In case you just want to build BCI2000 against a version of Qt outside the source tree, modify the file BCI2000/build/cmake/FindQt.cmake, line 10, to read SET( USE_STD_QT TRUE ), and re-run CMake.

  • Download and install Qt on your machine.

Build and copy MSVC libraries and auxiliary files

  • In the file qt/mkspecs/win32-msvc2008/qmake.conf, add -Fd$(DESTDIR)$(QMAKE_TARGET).pdb as a compiler option to QMAKE_CFLAGS_DEBUG. In QMAKE_CFLAGS_RELEASE and QMAKE_CFLAGS_DEBUG, replace the -MD and -MDd with -MT and -MTd, respectively.
  • Open the VS2008 console window from the start menu, and from the Qt installation's qt directory, run configure with the following options:
-platform win32-msvc2008 
-static 
-no-sql-sqlite
-no-qt3support 
-fast 
-qt-zlib
-qt-gif 
-qt-libpng 
-qt-libmng 
-no-libtiff 
-no-libjpeg 
-no-phonon 
-no-webkit 
-no-scripttools 
-no-style-plastique 
-no-style-motif 
-no-style-cde 
  • When prompted for the type of license, choose "Open Source", and answer "yes" when asked whether you accept the terms of the license.
  • Run nmake in the following directories:
    • qt/src/corelib,
    • qt/src/gui,
    • qt/src/winmain,
    • qt/src/opengl.
  • Copy the following files from qt/bin to BCI2000/src/extlib/qt/msvc/bin:
findtr
idc.exe
moc.exe
qmake.exe
rcc.exe
syncqt
uic.exe
libgcc_s_dw2-1.dll
mingwm10.dll

Make sure to leave the qt.conf file unaffected.

  • From qt/lib, copy the following files to BCI2000/src/extlib/qt/msvc/lib:
QtCore.lib
QtCored.lib
QtCored.pdb
QtGui.lib
QtGuid.lib
QtGuid.pdb
qtmain.lib
qtmaind.lib
qtmaind.pdb
QtOpenGL.lib
QtOpenGLd.lib
QtOpenGLd.pdb
  • From qt/mkspecs, copy the file qconfig.pri, and recursively copy the contents of the features directory and all the win32-msvc* directories to BCI2000/src/extlib/qt/msvc/mkspecs.
  • In BCI2000/src/extlib/qt/msvc/mkspecs/win32-msvc2008/qmake.conf, remove the -Fd$(DESTDIR)$(QMAKE_TARGET).pdb compiler option from QMAKE_CFLAGS_DEBUG.

Note: Why do we need debug libraries and pdb files?

For the stripped-down version of Qt provided in the BCI2000 source tree, no source code is available, and debugging information in the Qt libraries cannot be used for debugging. Thus, it appears that always linking to the release version of the Qt libraries would be sufficient, saving considerable space in the SVN data base, and download time for the user. Unfortunately, it turns out that this is not sufficient, and that both debugging versions of the Qt libraries, and associated pdb files, are required in the BCI2000 source tree.

  • MSVC does not cleanly separate between compile and link stages. Rather, the compiler provides /M switches that determine the runtime libraries to be used in the linking stage.
  • Due to this dependency of object code on certain runtime libraries, it is not cleanly possible to link together static libraries compiled with one /M switch with application code compiled with another /M switch. Thus, we need to provide both release and debug versions of the Qt libraries.
  • Without the pdb files, thousands of LNK4099 warnings are generated by the linker.
  • LNK4099 indicates that no debugging information can be found for the static libraries being linked into a BCI2000 executable. Suppressing this warning would be the appropriate thing to do, as no source files are available for the Qt libs anyway.
    • MSVC does not offer a command line switch/project setting for suppressing linker warnings.
    • For each source file inside a static library, and for each BCI2000 executable, separate LNK4099 warnings are generated, adding up to thousands of them.
  • Trying the -Z7 switch (to include debug information in the libraries themselves) when building Qt as well as BCI2000 resulted in build failures, so we switched back to -Zi (pdb files).
  • The -Fd$(DESTDIR)$(QMAKE_TARGET).pdb compiler option is required in order to produce correctly named pdb files in the appropriate location, i.e. in the qt library directory.

Build and copy mingw libraries and auxiliary files

  • From the Qt installation's qt directory, run configure with the following options:
-platform win32-g++
-static 
-no-sql-sqlite
-no-qt3support 
-fast 
-qt-zlib
-qt-gif 
-qt-libpng 
-qt-libmng 
-no-libtiff 
-no-libjpeg 
-no-phonon 
-no-webkit 
-no-scripttools 
-no-style-plastique 
-no-style-motif 
-no-style-cde 
  • When prompted for the type of license, choose "Open Source", and answer "yes" when asked whether you accept the terms of the license.
  • Open a console window, and run mingw32-make in the following directories:
    • qt/src/corelib,
    • qt/src/gui,
    • qt/src/winmain,
    • qt/src/opengl.
  • When the build is finished, copy the following files from qt/bin to BCI2000/src/extlib/qt/mingw/bin:
findtr
idc.exe
moc.exe
qmake.exe
rcc.exe
syncqt
uic.exe
libgcc_s_dw2-1.dll
mingwm10.dll

Leave the qt.conf file in place, don't modify it.

  • From qt/lib, copy the following files to BCI2000/src/extlib/qt/mingw/lib:
libQtCore.a
libQtGui.a
libqtmain.a
libQtOpenGL.a
*From qt/mkspecs, copy the file qconfig.pri, and recursively copy the contents of directories features, common, and win32-g++ to BCI2000/src/extlib/qt/mingw/mkspecs.

Copy Qt include files to the BCI2000 directory

  • Most header files point to header files in the qt/src header files. We don't want to provide the entire qt/src directory, so we need to replace these header files with the content of the files they point to. There is a fixheader tool provided in the BCI2000 source tree at build/buildutils/fixheader.cpp. Under cygwin, execute
make fixheader

from that directory to build the executable. Then, cd to the qt/include/Qt directory of your Qt installation, and execute

for i in `find *.h`; do /full/path/to/fixheader $i; done

Repeat this step for the QtCore, QtGui, and QtOpenGL include directories.

  • Copy the contents of the directory qt/include/Qt into BCI2000/src/extlib/qt/include/Qt, omitting the private directory.
  • Likewise, copy the QtCore, QtGui, and QtOpenGL include directories to BCI2000/src/extlib/qt/include, omitting the respective private directories.

See also

Programming Reference:Build System