Git tips

Show files status

git status #show all files
git statis -u -s #show untracked in short listing

Commit with message

git commit -m"text"

Recursive add files by mask to git

git add *.mask -A

Linux-recursive remove some files

find -iname '*mask' | xargs rm

How to create global .gitignore file

git config --global core.excludesfile /file-path/.gitignore-global

TENG – c++ templating engine

Project site: http://teng.sourceforge.net/?page=home

External project documentation: http://teng.olmik.net/

Latest TENG source code: http://teng.cvs.sourceforge.net/teng/ (Note: Source code referenced from main site isn’t latest! )

How to compile TENG on windows

Compilation under Windows is possible only using MinGW and with few modifications in TENG code (because there is few glitch which didn’t meet c++ standards). If you want more information or updated TENG version, please let me know.

How to compile open-source libraries under Windows using MinGW

Lots of open source libraries (like libiconv, libintl, …) doesn’t have MSVC project files or makefiles. Only supported way how to compile given library under Window is using MinGW and MSYS compiler tools.

Here is step-by-step guide how to download, install and compile libraries using MinGW.

Step one download MinGW

From MinGW home web site http://www.mingw.org/ download “Automated MinGW Installer”. Current version could be downloaded here: http://sourceforge.net/projects/mingw/files_beta/Automated MinGW Installer

Step two installing

Run downloaded executable. As install directory leave C:\MinGW. It’s recommended not to change this path.  On component screen select C compiler, C++compiler, MSYS Basic System and MinGW Developer Toolkit.

After that select next,next,next, finish ;-). After that installer downloads all necessary files. This could take a few minutes.

When installation is done, as next step is necessary to setup PATH variable to c:\MinGW. Installer doesn’t modify it automatically. (more info about modifying PATH variable) .

Installing additional gcc compiler and make support

These two packages isn’t listed in available components. If you wish to install it, use mingw-get-inst. In c:\MinGW\bin directory run following commands:

mingw-get install gcc g++ mingw32-make msys-base

Step three compiling

Compiling from windows shell

Launch cmd tool, go to directory with source code and use g++.

g++ test.cpp

Compiling from MinGW console

Launching MinGW console

Laung MinGW from startmenu or msys.bat from %INSTALL_PATH%\MinGW\msys\1.0\msys.bat.

How to compile libiconv library

As first, download latest libiconv source files from http://www.gnu.org/software/libiconv. And extract whole package somewhere on your disk.

Launch MinGW console and go to the extracted directory. When you extracted directory to the path:

p:\DependentLibrariesWhole\libiconv-1.13.1

Type following command to MinGW console:

cd /p/DependentLibrariesWhole/libiconv-1.13.1

after that, run configure with required library params (in our case we want static and dynamic version of library):

configure --enable-static --enable-shared

and than run make

make

Compiled libraries are located in directory “libiconv-1.13.1\lib\.libs”. There is  additional information about building libiconv library on stackoverflow.

Additional How to guides

This list is compilation of answer to questions and informations how to solve some problems which I had during my installations.

How to get list of available parameters for configure script?

Use “configure –help” command.

Qt correct setup for QMAKESPEC, QTDIR and PATH

When you want to use different configurations for different platforms in your .pro file, it’s necessary to correctly setup three variables: QMAKESPEC, QTDIR and PATH.

Here is how to configure for different platforms:

Microsoft Windows:

In SystemPropertes -> Enviroment variables add/update following values:

QTDIR = P:\QT\4.7.0
PATH = %QTDIR%\bin
QMAKESPEC=%QTDIR%\mkspecs\win32-msvc2005
LANG = en_US

Unix Bourne shell: (not tested)

QMAKESPEC=/usr/local/qt/mkspecs/linux-g++
PATH=$PATH:/local/qmake/bin
export QMAKESPEC PATH</pre>

Unix C shell: (not tested)

setenv QMAKESPEC /usr/local/qt/mkspecs/linux-g++
setenv PATH $PATH:/local/qmake/bin</pre>

Note

You can optionally use LANG variable to setup QtCreator language.

Old qt 3.0 guide: http://doc.trolltech.com/3.0/qmake-guide.html
How to configure enviroment: http://doc.qt.nokia.com/4.0/qmake-environment-reference.html

First Qt attempts – qmake troubles

External links

qmake documentation: qmake tutorial.html
qmake variables: qmake variable reference

Generate vcproj from .pro file

Command line for generating Visual studio project file from Qt .pro file.

qmake -tp vc test.pro

Missing moc_*.cpp file

When some of moc file isn’t properly generated and getting following error:

c1xx : fatal error C1083: Cannot open source file: '.\debug\moc_xxx.cpp': No such file or directory

try following:
Select corresponding .h file (for moc_xxx.cpp select xxx.h) in a project tree and select Compile from context menu. If the file is marked as “up-to-date“, try to change something in this file and repeat a compilation. If in the output window will be “up-to-date” again, you found a problem.

Use context menu on the corresponding .h file, select properties and edit “Configuration properties |Custom build steps|General|Outputs” to any value (add some char to the end of value), confirm change by Ok button and then return value back to original (remove added char). After that, compilation on correspond file will be successfully performed.

Linux relevant tips

List of known issues and tips

This is list of all known issues and problems which we had to solve during our first Qt installation on Linux, Windows and Mac.

Known errors

Error: undefined interface

What to do when compilation of QT crash with message “Error: undefined interface”.
http://www.qtforum.org/article/31561/error-when-building-libraries.html
http://www.qtcentre.org/threads/26245-Qt-4.6-api/qscriptextensionplugin.h(43)-Error-Undefined-interface

make: g++: Command not found

it’s necessary to instal g++ support (sudo apt-get install g+)

Basic XLib functionality test failed!

it’s necessary to instal xlib(xorg??) support (sudo apt-get install xorg-dev)

*** [sub-corelib-make_default-ordered] Error 2

Probably mishmash on 32bit / 64bit  system and QT versions.

undefined reference to `QEventDispatcherGlib::versionSupported()’

Probably missing libglib2.0-dev on your system. (sudo apt-get install libglib2.0-dev).

Undefined reference to QSslSocket::*

Missing OpenSSL library on your system. (sudo apt-get install libssl-dev)

gtk/gtk.h: No such file or directory

Missing gtk package. (sudo apt-get install libgtk2.0-dev ). After that its necessary to update db (sudo updatedb).

if system can’t find file gtk/gtk.h because gtk is stored in gtk-2.0 directory, add -I (capitalised i) param to configure with gtk path:

./configure -opensource -I /usr/include/gtk-2.0

cups/cups.h: No such file or directory

install libcups2. (sudo apt-get install libcups2-dev)

gst/gst.h: No such file or directory

install gstreamer 0.10. (sudo apt-get install libgstreamer0.10-dev)

Missing Include/glibconfig.h

it’s because this file isn’t in /usr/include/glib-2.0, but in /usr/lib/glib-2.0. So you have to include also this /usr/lib path or copy file to include/glib-2.0

Hints and tips

How to create symbolic link to directory

create symbolic link using ln -nsf /usr/include/gtk-2.0/gtk /usr/include/gtk

Minimal required libraries

List of libraries required by Qt:

  • libfontconfig1-dev
  • libfreetype6-dev
  • libx11-dev
  • libxcursor-dev
  • libxext-dev
  • libxfixes-dev
  • libxft-dev
  • libxi-dev
  • libxrandr-dev
  • libxrender-dev

And other which are required by some modules of Qt:

To install all required on Linux, use following commands

sudo apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxcursor-dev libxext-dev libxfixes-dev libxcups/cups.h: No such file or directory ft-dev libxi-dev libxrandr-dev libxrender-dev

sudo apt-get install bison flex libqt4-dev libqt4-opengl-dev libphonon-dev libicu-dev libsqlite3-dev libxext-dev libxrender-dev gperf libfontconfig1-dev libphonon-dev

If error doesn’t disappear after installing correct library

Sometimes it’s necessary to reconfigure Qt using make confclean

How to find where is missing header file located on disk

Use find /path -iname xxx.h command

How to find package which contains missing header file

use apt-file application with following syntax:

apt-file search gdk/gdk.h

Useful links about instalation Qt on linux

List of links about installation:
Building Qt on Linux

Qt configuration for succesfull build

This is currently my latest configure command to compile Qt on my Ubuntu 10.10.

Compilation fixes

This is necessary when search path for following libraries isn’t entered to configure.

sudo ln -nsf /usr/include/gstreamer-0.10/gst /usr/include/gst

Todo

Figure out how works pkg-config (pkg-config –cflags gstreamer-0.10)

Qt installation and configuration

This is our company step-by-step guide to install and configure Qt on our developer machines.

How to install Qt

Link to Qt download site: http://qt.nokia.com/downloads

Windows (VS2005)

Download VS 2008 distribution from download site. When 2008 distribution is downloaded, it’s necessary to reconfigure and rebuild it for VS 2005 using next steps.

Linux

Download linux/x11 distro from Qt page. Download 32/64bit distro package. Setup downloaded files as executables:

chmod +x qt-sdk-linux-x86-opensource-2009.01.bin
chmod +x qt-creator-linux-x86-opensource-1.0.0.bin

Install Qt sdk to default directory and begin with configuration.

MacOS

Download latest Qt SDK distribution and latest XCode developer pack from apple site. Then install both.

How to configure Qt

Qt configuration is done via Configure script/executable on all platforms.

Windows

Run “Start menu->Visual studio->Tools-> Visual studio command prompt”
Then go to “c:\Qt\Qt_Version\Qt” and run “configure” with additional params.

Our current configuration:

configure -debug-and-release -opensource -shared -platform win32-msvc2005 -incredibuild-xge -openssl

Clean configurations

run nmake confclean and nmake distclean to remove all previous version of QT compilations.

SSL support

For SSL Support add -openssl switch to configure.

Note!

: configure param HAVE TO be executed from Visual studio command prompt!

Linux

Enter Qt directory and enter following configure param:

./configure -opensource -I /usr/include/gtk-2.0 -L /usr/lib/gt-2.0 -I  /usr/include/gstreamer-0.10 -L /usr/lib/gstreamer-0.10 -I /usr/include/glib-2.0 -L /usr/lib/glib-2.0 -I /usr/include/libxml2 -fast

Clean configurations

run make confclean and then configure.

MacOS

How to compile Qt

Windows

Compile Qt using command prompt:

  • Run Visual studio command prompt.
  • And run nmake to build a whole library

Second option is open projects.sln located in p:/Qt/4.7.1/ using Visual Studio IDE  and compile it.

Linux

  • As first thing, use configure to setup Qt settings.
  • As next, run make to build a whole library
  • After a while when everything is compiled, use make install. This will install library to /usr/local/Trolltech/Qt-4.7.0

MacOS

Currently not tested, using default compilation.

How to compile application

When we have prepared Qt library, it’s time to compile our application.

MacOS

When using  qmake without additional params, qmake generate xcode project from .pro instad makefile for g++. To generate makefile, use following params:

qmake -spec macx-g++
make

Deploying application

Windows

Not testes.

External link: http://doc.trolltech.com/4.5/deployment-windows.html

Linux

Not testes.

MacOS

Not testes.