Showing posts with label Qt. Show all posts
Showing posts with label Qt. Show all posts

Friday, July 15, 2011

Running a Qt application without the IDE on Windows

When writing a Qt application, you may find yourself at the point where you need to run the program without the IDE. If you have the paid-for version, that isn't so hard, as everything should be compiled into the executable. But if you are using the LGPL version, your executable needs to have the Qt dlls close at hand, either in the same folder or in your path. I found this forum to be useful:

http://www.qtforum.org/article/24337/error-running-qt-application.html

To make things complicated, there are actually 2 sets of dlls with the same name. tymek's post was what helped me: you have to get the dlls from the \qt\bin folder, not the \bin folder. I believe one set is for debug versions, and one set is for release versions of your program, but I could be wrong.

Tuesday, February 8, 2011

Compiling FreeType-2.4.4 with the MinGW compiler bundled with Qt on Windows XP

I have a Qt application that uses OpenGL directly to render some things. Consequently, I wanted to add text support in OpenGL. After looking at a few options, trying one option and rejecting it, I decided to try FTGL. FTGL needs Freetype to compile, so I had to try and install Freetype. I went with Freetype-2.4.4 to get some of the new features, so I had to compile it from source (the pre-built version was only at 2.3.5). I ran into some interesting problems while compiling. The error looked something like this:

>mingw32-make
process_begin: CreateProcess(NULL, type builds\newline, ...) failed.
make (e=2): The system cannot find the file specified.
mingw32-make: *** [dos_setup] Error 2

After scouring through many of the makefiles, I finally narrowed the problem to the builds\detect.mk file. Specifically, starting at line 134. After puzzling about that for a while, I finally managed to figure out the reason: I had cygwin binaries in the path. They were conflicting with the mingw files. Removing the cygwin files from the path fixed the problem:

>mingw32-make

FreeType build system -- automatic system detection

The following settings are used:

  platform                     win32
  compiler                     gcc
  configuration directory      .\builds\win32
  configuration rules          .\builds\win32\w32-gcc.mk

If this does not correspond to your system or settings please remove the file
'config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type 'make' again to build the library.
or 'make refdoc' to build the API reference (the latter needs python).

Doing another 'mingw32-make' command finished up the compilation, putting the resulting files in \objs.

Now we'll see if it works...

Edit:

It did indeed work. I copied libfreetype.a to mingw/lib. I also copied ft2build.h and the freetype folder with the other header files to mingw/include. Using the library involved including the appropriate headers:

#include <ft2build.h>
#include FT_FREETYPE_H

- and then following the example on the Freetype website. The only other problem was that the Qt .pro file needed to be updated to include the following line:

LIBS += -lfreetype