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.

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.

Improved icons list with new skin

Today I continued with UI skinning and enhancing visual feel from application. After few hours spent by searching a way how assign two different keyboard layouts to one screen (numerical for cash amount and alpha-numerical for comments), I gave it up and wrote to the Airplay forum. I hope that this function will not be a big problem and will be solved.

So result of my today work is full reworked icon list with automatic layout related to screen resolution and with full skin support. Here is result:


I realy like it and on iPhone with finger ability is icons-list much more better 😉

UI elements for iPhone GUI

Because Airplay SDK doesn’t have direct GUI support for iPhone applications, you have to skin all controls on your own. After a little search I found complete UI Photoshop .psd file where are all necessary controls in separate layers.

http://www.teehanlax.com/blog/2010/06/14/iphone-gui-psd-v4/

From this .psd file is then pretty simple to create your own .psd file which you used for exporting separated .png files to skin all UI controls.

Toolbar icons for iPhone UI

Because I started works on UI interface, I need some toolbar icons. After a lot of search, I found few sets which are nice and free, and few which are nice and paid ;-).

Here is compilation of UI sets links:
http://blog.twg.ca/2009/09/free-iphone-toolbar-icons/ (160 icons for free)
http://glyphish.com/ (130 icons for free, next 80 paid)
http://smykes24.deviantart.com/art/iPhone-Tab-Bar-Icons-Gaming-129467506
http://tabs.icondesign.dk/ (few for free, rest of them paid)
http://www.app-bits.com/free-icons.html (64 icons for free)
http://www.dezinerfolio.com/freebie/30-free-vector-icons (30 vector icons for free)
http://www.iconsweets.com/ (60 free vector icons)

Paid icon sets:

http://www.icon2u.com/icon
http://www.iconsberlin.com/index_black.php (428 icons for 50 €)
http://www.iphonicon.com/ (260 icons for $79)
http://www.pixelpressicons.com/?page_id=118 (350 icons for $69)
http://www.eddit.com/shop/iphone_ui_icon_set/ (160 icons for $69)
http://www.kombine.net/icon-store/iphone-tab-bar-icons (130 icons for $60)
http://www.designkode.com/iphone-ipad-tab-bar-icons (150 icons for $50)
http://www.designkode.com/iphone-ipad-tab-bar-icons (1000 icons for $75)

First attempt with skin framework

Today I spent several hours by reading a documentation and trying lot of examples. Create UI to be like iOS as much as possible in Airplay will not be easy ;-). There is lot of obstacles that I will have to overcome to accomplish a desired GUI. Here is a result from my first day of work:

Airplay SDK is great framework for developing multi-platform applications (but primary games), but create nice iOS GUI is a real challenge ;-).

Application logic complete

Today I finished application logic coding and it seems that all works ok 😉 (or at least my unit test says that). Currently application can compute and simplify complicated loans relation and returns a result with minimal payback operations. Because a picture is better than thousand words, there are few examples:

On beginning, a simple example when Alice lends $10 John, and John lends $10 Bob. Instead of complicated payback from one person to another, there is a simply equal solution, where Bob will payback $10 directly to Alice:

Now little bit complicated example:

As you can see, after this optimization you save three steps.

And finally even more complex example:

Alice lends $100 John, John lends $50 Bob, Bob lends $20 Alice and Jane lends $10 Bob. Do you know how to payback money simply without duplicate the transfers? ;-).

And this is all for now. Application can handle also multiple loans to more people. I will try to prepare another examples of what application can do ;-).

Implemenation of simple DDX version

After windows implementation and action manager which makes my life a lot of easier, today I continue in extending of my UI framework builded upon Airplay SDK. I’m currently developing screens which have lot of input widgets and getting/setting data to this widget becomes a nightmare ;-). So, I implement simple DDX functions known from C++ MFC framework. This helps me to have a code much more cleaner and to maintain screens easier. And here are few screenshots from my today work:


Working on date selector under Airplay FW

A next goal during my work on the Party money application was a date selector. Because Airplay doesn’t have a native support for Apple Date widget, the whole element is created by using several CIwUIScrollableView controls. After few hours of trying to figured out how all things work I have finally working date selector ;-). Here is a screenshot from date selector with default (ugly ;-)) skin.

List of icons II.

Because list of icons looks really good for me, I decided to use it everywhere where it is possible ;-). I extend list classes, so buttons can have different sizes and customized captions. Besides icons choosing this widget will be used for displaying a person in a profile and for choosing person in a transactions.

List of Icons implementation

A next screen widget which I need for my Party cash application is scrollable grid of icons. What looks simply became a problem which needs several hours ;-). Again, because Airplay SDK doesn’t have any prepared widget, I have to create a new by using several existing ones. Result looks very promising, but currently without a final skin. So buttons have ugly default gray skin ;-).

Simple window framework for Airplay SDK

Altough I still explore lot of features and possibilities of Airplay framework, definitely I know that framework has only limited support for complex UI applications. Guys from Airplay SDK do a lot of work for 2D and 3D applications, and have a basic support for creating and skinning app windows and widgets. But what I really miss is some layer which helps you with window creating, event handling and so on.

So, I decided to create one on my own which is based on my another project Atomix – a large project for Visual C++. Currently I have implemented a window manager and action manager for Airplay SDK. So now, instead of writing lot of code for creating and handling windows, I have everything encapsulated in few objects and all my screen objects are derived from these base clases.

Still a lot of work has to be done to achieve the final application 😉

Continue reading