Programming Reference:Building Qt for BCI2000 (obsolete): Difference between revisions

From BCI2000 Wiki
Jump to navigation Jump to search
No edit summary
Line 6: Line 6:
*Download the Qt source code [http://qt-project.org/downloads] to your machine.
*Download the Qt source code [http://qt-project.org/downloads] to your machine.
*Outside the Qt source tree, create a directory tree, e.g. <tt>d:\Qt\5.3\build-msvc12</tt>. A Qt build may require an enormous amount of temporary disk space (50GB and more), so it is recommended to build Qt on a separate (virtual) empty disk drive.
*Outside the Qt source tree, create a directory tree, e.g. <tt>d:\Qt\5.3\build-msvc12</tt>. A Qt build may require an enormous amount of temporary disk space (50GB and more), so it is recommended to build Qt on a separate (virtual) empty disk drive.
*Open the file <tt>qt/mkspecs/win32-msvc2008/qmake.conf</tt> in a text editor.
*Within the newly created empty build directory, place a <tt>do_configure.bat</tt> script file with the following content:
*Open the file <tt>qt/projects.pro</tt>, and put a comment sign in front of "examples demos" near the top of the file.
*Open the VS2008 console window from the start menu, and from the Qt installation's <tt>qt</tt> directory, run <tt>configure</tt> with the following options:
-platform win32-msvc2008
-static
-no-sql-sqlite
-no-qt3support
-fast
-qt-zlib
-qt-libpng
-qt-libmng
-no-libtiff
-no-libjpeg
-no-phonon
-no-webkit
-no-scripttools
-no-style-plastique
-no-style-motif
-no-style-cde
As a full command line:
configure -platform win32-msvc2008 -static -no-sql-sqlite -no-qt3support -fast -qt-zlib -qt-libpng -qt-libmng -no-libtiff -no-libjpeg -no-phonon -no-webkit -no-scripttools -no-style-plastique -no-style-motif -no-style-cde


c:\Qt\5.3\Src\configure ^
-platform win32-msvc2012 ^
-static ^
-prefix d:\Qt\deployment\qt-5.3.2\win32-msvc2012 ^
-headerdir ..\include ^
-no-vcproj -mp ^
-no-openssl -no-qml-debug ^
-opengl desktop ^
-skip qtdeclarative ^
-skip qtquick1 ^
-skip qtquickcontrols ^
-skip qtscript ^
-skip qtwebkit ^
-skip qtwebkit-examples ^
-skip qtxmlpatterns ^
-nomake tests ^
-nomake examples
*This should be a single command line, so make sure that the caret character is actually the last character in each line, and not followed by white space.
*Note that the first path should point to your Qt source location, and the "prefix" path should point to a location on your build drive. This is the path that will contain Qt headers and libraries after the build.
*In your Qt source directory, open the file <tt>qtbase/mkspecs/win32-msvc2012/qmake.conf</tt> in a text editor.
*Open the appropriate Visual Studio console window from the start menu. Whether you build a 64 or 32 bit version of Qt will depend on the type of VS Command Prompt you choose.
*Change directory to the build directory containing the script described above, and execute it.
*When prompted for the type of license, choose "Open Source", and answer "yes" when asked whether you accept the terms of the license.
*When prompted for the type of license, choose "Open Source", and answer "yes" when asked whether you accept the terms of the license.
*Run <tt>nmake</tt> as suggested by <tt>configure</tt>.
*Run <tt>nmake</tt> as suggested by <tt>configure</tt>.

Revision as of 12:22, 8 August 2015

This document describes how to build Qt for installation in the BCI2000 source tree. It is current as of Qt 5.3.

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, run CMake a first time, then open the file BCI2000/build/CMakeCache.txt in the CMake GUI, or in a text editor, and set the value of the USE_EXTERNAL_QT option to "ON".

Build and copy MSVC libraries and auxiliary files

  • Download the Qt source code [1] to your machine.
  • Outside the Qt source tree, create a directory tree, e.g. d:\Qt\5.3\build-msvc12. A Qt build may require an enormous amount of temporary disk space (50GB and more), so it is recommended to build Qt on a separate (virtual) empty disk drive.
  • Within the newly created empty build directory, place a do_configure.bat script file with the following content:
c:\Qt\5.3\Src\configure ^
-platform win32-msvc2012 ^
-static ^
-prefix d:\Qt\deployment\qt-5.3.2\win32-msvc2012 ^
-headerdir ..\include ^
-no-vcproj -mp ^
-no-openssl -no-qml-debug ^
-opengl desktop ^
-skip qtdeclarative ^
-skip qtquick1 ^
-skip qtquickcontrols ^
-skip qtscript ^
-skip qtwebkit ^
-skip qtwebkit-examples ^
-skip qtxmlpatterns ^
-nomake tests ^
-nomake examples
  • This should be a single command line, so make sure that the caret character is actually the last character in each line, and not followed by white space.
  • Note that the first path should point to your Qt source location, and the "prefix" path should point to a location on your build drive. This is the path that will contain Qt headers and libraries after the build.
  • In your Qt source directory, open the file qtbase/mkspecs/win32-msvc2012/qmake.conf in a text editor.
  • Open the appropriate Visual Studio console window from the start menu. Whether you build a 64 or 32 bit version of Qt will depend on the type of VS Command Prompt you choose.
  • Change directory to the build directory containing the script described above, and execute it.
  • 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 as suggested by configure.
  • Inside the qt-x.y.z directory, create a subdirectory win32-msvc2008.
  • Copy the following files from qt/bin to qt-x.y.z/win32-msvc2008/bin:
idc.exe
moc.exe
qmake.exe
rcc.exe
uic.exe

Make sure to leave the qt.conf file unaffected.

  • From qt/lib, copy the following files to qt-x.y.z/win32-msvc2008/lib:
QtCore.lib
QtCored.lib
QtGui.lib
QtGuid.lib
QtOpenGL.lib
QtOpenGLd.lib
  • From qt/mkspecs, copy the file qconfig.pri, and recursively copy the contents of the features and the win32-msvc2008 directories to qt-x.y.z/win32-msvc2008/mkspecs.
  • Repeat the entire process with MSVC2010, with results going into a win32-msvc2010 directory rather than the win32-msvc2008 directory.
  • For 64-bit versions of the libraries, proceed as above, but run configure and nmake steps from a 64-bit Visual Studio command line prompt. The target directory should be named win32-amd64-msvc2008 for MSVC 2008 64-bit builds.

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-libpng 
-qt-libmng 
-no-libtiff 
-no-libjpeg 
-no-phonon 
-no-webkit 
-no-scripttools 
-no-style-plastique 
-no-style-motif 
-no-style-cde 

The full command line is:

configure -platform win32-g++ -static -no-sql-sqlite -no-qt3support -fast -qt-zlib -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.
  • If you have previously done a full build, open a console window, and run mingw32-make in the following directories:
    • qt/src/corelib,
    • qt/src/gui,
    • qt/src/opengl.
  • Otherwise, run mingw32-make from the qt/src directory.
  • When the build is finished, copy the following files from qt/bin to qt-x.y.z/win32-g++/bin:
idc.exe
moc.exe
qmake.exe
rcc.exe
uic.exe
libgcc_s_dw2-1.dll
mingwm10.dll

If the DLL files do not exist, they are not required. Leave the qt.conf file in place, don't modify it.

  • From qt/lib, copy the following files to qt-x.y.z/win32-g++/lib:
libQtCore.a
libQtGui.a
libQtOpenGL.a
  • From qt/mkspecs, copy the file qconfig.pri, and recursively copy the contents of directories features, common, and win32-g++ to qt-x.y.z/win32-g++/mkspecs.

Add configuration information

  • To each of the bin directories created in previous steps, add a file qt.conf with the following content:
[Paths]
Prefix=
Documentation=../doc
Headers=../../include
Libraries=../lib
Binaries=
Plugins=../plugins
Data=..
Translations=../translations
Settings=
Examples=
Demos=

Prepare Qt include files for external use

  • 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
g++ fixheader.cpp -o 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 qt-x.y.z/include/Qt, omitting the private directory.
  • Likewise, copy the QtCore, QtGui, QtOpenGL include directories to qt-x.y.z/include, omitting the respective private directories.

Hide debugging information in MSVC libraries

  • Despite current MSVC compilers store debugging information in .pdb files, .lib files still contain traditional debugging information. In addition, .lib debugging information refers to .pdb files, and the MSVC linker will issue a large number of warnings if it cannot find those .pdb files.
  • Basically, we might use GNU binutils, which are able to handle COFF binaries, in order to strip debugging information from those libraries. However, it seems that MSVC compilers store information in such a way that it is not possible to remove arbitrary sections without breaking the files. Thus, we keep all sections but change names of debugging sections such that the MSVC linker will not be able to identify them as such. While this has the disadvantage of retaining large file sizes, it still provides the benefit of fast linking, and suppression of linker warnings.
  • To hide debugging information, open a cygwin shell, and cd to the qt lib directory that contains MSVC libraries. There, execute
/full/path/to/build/buildutils/strip_msvc_lib.sh *

Upload Qt to the BCI2000 server

  • Create a self-extracting 7z archive from each subfolder of the qt-x.y.z directory. In order to expand correctly, the archive must contain the qt-x.y.z directory as well.
  • For CMake to find an archive on the server, it must be located at the following http path: /externals/qt/qt-x.y.z.subdirname

Note that archives may not have an .exe file extension on the server. It will be added when the file is downloaded by CMake (see BCI2000/build/cmake/FindQt.cmake for details).

See also

Programming Reference:Build System