Neste pequeno artigo vou mostrar algumas dicas ao se compilar a Qt no Debian lenny. Pretendo mostrar dicas de compilação da Qt no Debian, que usa pacotes .deb e o gerenciador de pacotes APT.
Em outro artigo pretendo mostrar dicas de compilação da Qt em uma distribuição com gerenciador de pacotes RPM.
Compilar a Qt no Linux é muito fácil, geralmente mais fácil do que no Windows®, o que você tem a fazer é certificar-se de que os recursos que você pretende habilitar durante a configuração estão presentes no sistema, no caso do Debian isto significa procurar pelos pacotes que o script configure ira verificar se estão instalados.

Para vários recursos que a Qt disponibiliza, existe a opção de habilita-los ou não durante a compilação, ou então pode acontecer de algum recurso que você queira esteja desabilitado porque o configure não encontrou o pacote com as dependências instalado no sistema.
Por exemplo, no Linux os bancos de dados instalados são identificados automaticamente pelo configure desde que estejam instalados no caminho padrão, vejamos o que diz a documentação da Qt:

Building the Drivers Using Configure

On Unix and Mac OS X, the Qt configure script tries to automatically detect the available client libraries on 
your machine. Run configure -help to see what drivers can be built. You should get an output similar to this:

 -no-sql- ... Disable SQL  entirely.
 -qt-sql- ... Enable a SQL  in the Qt Library, by default
                      none are turned on.
 -plugin-sql- Enable SQL  as a plugin to be linked to
                      at run time.

                      Possible values for :
                      [ db2 ibase mysql oci odbc psql sqlite sqlite2 tds ]


No console, vá até o diretório onde esta o script configure e dite: ./configure --help | less
Veja o exemplo no meu computador:
rodolfo@Programador:~/tmp/QT4.5.3/qt-x11-opensource-src-4.5.3$ ./configure --help | less

Você tera a seguinte saida:

Usage:  configure [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir ]
        [-docdir ] [-headerdir ] [-plugindir  ] [-datadir ]
        [-translationdir ] [-sysconfdir ] [-examplesdir ]
        [-demosdir ] [-buildkey ] [-release] [-debug]
        [-debug-and-release] [-developer-build] [-shared] [-static] [-no-fast] [-fast] [-no-largefile]
        [-largefile] [-no-exceptions] [-exceptions] [-no-accessibility]
        [-accessibility] [-no-stl] [-stl] [-no-sql-] [-sql-]
        [-plugin-sql-] [-system-sqlite] [-no-qt3support] [-qt3support]
        [-platform] [-D ] [-I ] [-L ] [-help]
        [-qt-zlib] [-system-zlib] [-no-gif] [-qt-gif] [-no-libtiff] [-qt-libtiff] [-system-libtiff]
        [-no-libpng] [-qt-libpng] [-system-libpng] [-no-libmng] [-qt-libmng]
        [-system-libmng] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg] [-make ]
        [-no-make ] [-R ]  [-l ] [-no-rpath]  [-rpath] [-continue]
        [-verbose] [-v] [-silent] [-no-nis] [-nis] [-no-cups] [-cups] [-no-iconv]
        [-iconv] [-no-pch] [-pch] [-no-dbus] [-dbus] [-dbus-linked]
        [-no-separate-debug-info] [-no-mmx] [-no-3dnow] [-no-sse] [-no-sse2]
        [-qtnamespace ] [-qtlibinfix ] [-separate-debug-info] [-armfpa]
        [-no-optimized-qmake] [-optimized-qmake] [-no-xmlpatterns] [-xmlpatterns]
        [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend]
        [-no-openssl] [-openssl] [-openssl-linked]
        [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit]
        [-no-scripttools] [-scripttools]

        [additional platform specific options (see below)]


Installation options:

 These are optional, but you may specify install directories.

    -prefix  ...... This will install everything relative to 
                         (default /usr/local/Trolltech/Qt-4.5.3)

  * -prefix-install .... Force a sandboxed "local" installation of
                         Qt. This will install into
                         /usr/local/Trolltech/Qt-4.5.3, if this option is
                         disabled then some platforms will attempt a
                         "system" install by placing default values to
                         be placed in a system location other than
                         PREFIX.

 You may use these to separate different parts of the install:

    -bindir  ......... Executables will be installed to 
                            (default PREFIX/bin)
    -libdir  ......... Libraries will be installed to 
                            (default PREFIX/lib)
    -docdir  ......... Documentation will be installed to 
                            (default PREFIX/doc)
    -headerdir  ...... Headers will be installed to 
                            (default PREFIX/include)
    -plugindir  ...... Plugins will be installed to 
                            (default PREFIX/plugins)
    -datadir  ........ Data used by Qt programs will be installed to 
                            (default PREFIX)
    -translationdir  . Translations of Qt programs will be installed to 
                            (default PREFIX/translations)
    -sysconfdir  ..... Settings used by Qt programs will be looked for in 
                            (default PREFIX/etc/settings)
    -examplesdir  .... Examples will be installed to 
                            (default PREFIX/examples)
    -demosdir  ....... Demos will be installed to 
                            (default PREFIX/demos)

 You may use these options to turn on strict plugin loading.

    -buildkey  .... Build the Qt library and plugins using the specified
                         .  When the library loads plugins, it will only
                         load those that have a matching key.

Configure options:

 The defaults (*) are usually acceptable. A plus (+) denotes a default value
 that needs to be evaluated. If the evaluation succeeds, the feature is
 included. Here is a short explanation of each option:

 *  -release ........... Compile and link Qt with debugging turned off.
    -debug ............. Compile and link Qt with debugging turned on.
    -debug-and-release . Compile and link two versions of Qt, with and without
                         debugging turned on (Mac only).

    -developer-build.... Compile and link Qt with Qt developer options (including auto-tests exporting)

    -opensource......... Compile and link the Open-Source Edition of Qt.
    -commercial......... Compile and link the Commercial Edition of Qt.


 *  -shared ............ Create and use shared Qt libraries.
    -static ............ Create and use static Qt libraries.

 *  -no-fast ........... Configure Qt normally by generating Makefiles for all
                         project files.
    -fast .............. Configure Qt quickly by generating Makefiles only for
                         library and subdirectory targets.  All other Makefiles
                         are created as wrappers, which will in turn run qmake.

    -no-largefile ...... Disables large file support.
 +  -largefile ......... Enables Qt to access files larger than 4 GB.

    -no-exceptions ..... Disable exceptions on compilers that support it.
 *  -exceptions ........ Enable exceptions on compilers that support it.

    -no-accessibility .. Do not compile Accessibility support.
 *  -accessibility ..... Compile Accessibility support.

    -no-stl ............ Do not compile STL support.
 *  -stl ............... Compile STL support.

    -no-sql- ... Disable SQL  entirely.
    -qt-sql- ... Enable a SQL  in the QtSql library, by default
                         none are turned on.
    -plugin-sql- Enable SQL  as a plugin to be linked to
                         at run time.

                         Possible values for :
                         [  db2 ibase mysql oci odbc psql sqlite sqlite2 tds ]

    -system-sqlite ..... Use sqlite from the operating system.

    -no-qt3support ..... Disables the Qt 3 support functionality.
 *  -qt3support ........ Enables the Qt 3 support functionality.

    -no-xmlpatterns .... Do not build the QtXmlPatterns module.
 +  -xmlpatterns ....... Build the QtXmlPatterns module.
                         QtXmlPatterns is built if a decent C++ compiler
                         is used and exceptions are enabled.

    -no-phonon ......... Do not build the Phonon module.
 +  -phonon ............ Build the Phonon module.
                         Phonon is built if a decent C++ compiler is used.
    -no-phonon-backend.. Do not build the platform phonon plugin.
 +  -phonon-backend..... Build the platform phonon plugin.

    -no-svg ............ Do not build the SVG module.
 +  -svg ............... Build the SVG module.

    -no-webkit ......... Do not build the WebKit module.
 +  -webkit ............ Build the WebKit module.
                         WebKit is built if a decent C++ compiler is used.

    -no-scripttools .... Do not build the QtScriptTools module.
 +  -scripttools ....... Build the QtScriptTools module.

    -platform target ... The operating system and compiler you are building
                         on (linux-g++).

                         See the README file for a list of supported
                         operating systems and compilers.
    -graphicssystem  Sets an alternate graphics system. Available options are:
                           raster - Software rasterizer
                           opengl - Rendering via OpenGL, Experimental!

    -no-mmx ............ Do not compile with use of MMX instructions.
    -no-3dnow .......... Do not compile with use of 3DNOW instructions.
    -no-sse ............ Do not compile with use of SSE instructions.
    -no-sse2 ........... Do not compile with use of SSE2 instructions.

    -qtnamespace   Wraps all Qt library code in 'namespace  {...}'.
    -qtlibinfix   Renames all libQt*.so to libQt*.so.

    -D  ........ Add an explicit define to the preprocessor.
    -I  ........ Add an explicit include path.
    -L  ........ Add an explicit library path.

    -help, -h .......... Display this information.

Third Party Libraries:

    -qt-zlib ........... Use the zlib bundled with Qt.
 +  -system-zlib ....... Use zlib from the operating system.
                         See http://www.gzip.org/zlib

    -no-gif ............ Do not compile the plugin for GIF reading support.
 *  -qt-gif ............ Compile the plugin for GIF reading support.
                         See also src/plugins/imageformats/gif/qgifhandler.h

    -no-libtiff ........ Do not compile the plugin for TIFF support.
    -qt-libtiff ........ Use the libtiff bundled with Qt.
 +  -system-libtiff .... Use libtiff from the operating system.
                         See http://www.libtiff.org

    -no-libpng ......... Do not compile in PNG support.
    -qt-libpng ......... Use the libpng bundled with Qt.
 +  -system-libpng ..... Use libpng from the operating system.
                         See http://www.libpng.org/pub/png

    -no-libmng ......... Do not compile the plugin for MNG support.
    -qt-libmng ......... Use the libmng bundled with Qt.
 +  -system-libmng ..... Use libmng from the operating system.
                         See http://www.libmng.com

    -no-libjpeg ........ Do not compile the plugin for JPEG support.
    -qt-libjpeg ........ Use the libjpeg bundled with Qt.
 +  -system-libjpeg .... Use libjpeg from the operating system.
                         See http://www.ijg.org

    -no-openssl ........ Do not compile support for OpenSSL.
 +  -openssl ........... Enable run-time OpenSSL support.
    -openssl-linked .... Enabled linked OpenSSL support.

    -ptmalloc .......... Override the system memory allocator with ptmalloc.
                         (Experimental.)

Additional options:

    -make  ....... Add part to the list of parts to be built at make time.
                         (libs tools examples demos docs translations)
    -nomake  ..... Exclude part from the list of parts to be built.

    -R  ........ Add an explicit runtime library path to the Qt
                         libraries.
    -l  ........ Add an explicit library.

    -no-rpath .......... Do not use the library install path as a runtime
                         library path.
 +  -rpath ............. Link Qt libraries and executables using the library
                         install path as a runtime library path. Equivalent
                         to -R install_libpath

    -continue .......... Continue as far as possible if an error occurs.

    -verbose, -v ....... Print verbose information about each step of the
                         configure process.

    -silent ............ Reduce the build output so that warnings and errors
                         can be seen more easily.

 *  -no-optimized-qmake ... Do not build qmake optimized.
    -optimized-qmake ...... Build qmake optimized.

    -no-nis ............ Do not compile NIS support.
 *  -nis ............... Compile NIS support.

    -no-cups ........... Do not compile CUPS support.
 *  -cups .............. Compile CUPS support.
                         Requires cups/cups.h and libcups.so.2.

    -no-iconv .......... Do not compile support for iconv(3).
 *  -iconv ............. Compile support for iconv(3).

    -no-pch ............ Do not use precompiled header support.
 *  -pch ............... Use precompiled header support.

    -no-dbus ........... Do not compile the QtDBus module.
 +  -dbus .............. Compile the QtDBus module and dynamically load libdbus-1.
    -dbus-linked ....... Compile the QtDBus module and link to libdbus-1.

    -reduce-relocations ..... Reduce relocations in the libraries through extra
                              linker optimizations (Qt/X11 and Qt for Embedded Linux only;
                              experimental; needs GNU ld >= 2.18).

    -no-separate-debug-info . Do not store debug information in a separate file.
 *  -separate-debug-info .... Strip debug information into a separate .debug file.


Qt/X11 only:

    -no-gtkstyle ....... Do not build the GTK theme integration.
 +  -gtkstyle .......... Build the GTK theme integration.

 *  -no-nas-sound ...... Do not compile in NAS sound support.
    -system-nas-sound .. Use NAS libaudio from the operating system.
                         See http://radscan.com/nas.html

    -no-opengl ......... Do not support OpenGL.
 +  -opengl  ...... Enable OpenGL support.
                         With no parameter, this will auto-detect the "best"
                         OpenGL API to use. If desktop OpenGL is avaliable, it
                         will be used. Use desktop, es1, es1cl or es2 for 
                         to force the use of the Desktop (OpenGL 1.x or 2.x),
                         OpenGL ES 1.x Common profile, 1.x Common Lite profile
                         or 2.x APIs instead. On X11, the EGL API will be used
                         to manage GL contexts in the case of OpenGL ES.

    -no-sm ............. Do not support X Session Management.
 *  -sm ................ Support X Session Management, links in -lSM -lICE.

    -no-xshape ......... Do not compile XShape support.
 *  -xshape ............ Compile XShape support.
                         Requires X11/extensions/shape.h.

    -no-xsync .......... Do not compile XSync support.
 *  -xsync ............. Compile XSync support.
                         Requires X11/extensions/sync.h.

    -no-xinerama ....... Do not compile Xinerama (multihead) support.
 *  -xinerama .......... Compile Xinerama support.
                         Requires X11/extensions/Xinerama.h and libXinerama.
			 By default, Xinerama support will be compiled if
                         available and the shared libraries are dynamically
                         loaded at runtime.

    -no-xcursor ........ Do not compile Xcursor support.
 *  -xcursor ........... Compile Xcursor support.
                         Requires X11/Xcursor/Xcursor.h and libXcursor.
			 By default, Xcursor support will be compiled if
                         available and the shared libraries are dynamically
                         loaded at runtime.

    -no-xfixes ......... Do not compile Xfixes support.
 *  -xfixes ............ Compile Xfixes support.
                         Requires X11/extensions/Xfixes.h and libXfixes.
			 By default, Xfixes support will be compiled if
                         available and the shared libraries are dynamically
                         loaded at runtime.

    -no-xrandr ......... Do not compile Xrandr (resize and rotate) support.
 *  -xrandr ............ Compile Xrandr support.
                         Requires X11/extensions/Xrandr.h and libXrandr.

    -no-xrender ........ Do not compile Xrender support.
 *  -xrender ........... Compile Xrender support.
                         Requires X11/extensions/Xrender.h and libXrender.

    -no-mitshm ......... Do not compile MIT-SHM support.
 *  -mitshm ............ Compile MIT-SHM support.
                         Requires sys/ipc.h, sys/shm.h and X11/extensions/XShm.h

    -no-fontconfig ..... Do not compile FontConfig (anti-aliased font) support.
 *  -fontconfig ........ Compile FontConfig support.
                         Requires fontconfig/fontconfig.h, libfontconfig,
                         freetype.h and libfreetype.

    -no-xinput.......... Do not compile Xinput support.
 *  -xinput ............ Compile Xinput support. This also enabled tablet support
                         which requires IRIX with wacom.h and libXi or
                         XFree86 with X11/extensions/XInput.h and libXi.

    -no-xkb ............ Do not compile XKB (X KeyBoard extension) support.
 *  -xkb ............... Compile XKB support.

    -no-glib ........... Do not compile Glib support.
 +  -glib .............. Compile Glib support.




Observe bem todos os parâmetros que você pode usar para habilitar ou desabilitar os diversos recursos.
Se quiser guardar esta saída em um arquivo texto, digite:

$ ./configure --help > saída_configure.txt

Quando for executar o configure já com os parâmetros que você quer, se quiser informações mais detalhadas na saída, que podem te ajudar a localizar erros, coloque o parâmetro -v

    -verbose, -v ....... Print verbose information about each step of the
                         configure process.


Se tudo correr bem, você deve ser capaz de encontrar este trecho na saída do configure:

       This target is using the GNU C++ compiler (linux-g++).

        Recent versions of this compiler automatically include code for
        exceptions, which increase both the size of the Qt libraries and
        the amount of memory taken by your applications.

        You may choose to re-run configure with the -no-exceptions
        option to compile Qt without exceptions. This is completely binary
        compatible, and existing applications will continue to work.


Build type:    linux-g++
Architecture:  i386
Platform notes:

            - Also available for Linux: linux-kcc linux-icc linux-cxx

qmake vars .......... cat: .qmake.vars: Arquivo ou diretório não encontrado
qmake switches ......
Build ............... libs tools examples demos docs translations
Configuration .......  release shared dll largefile stl precompile_header separate_debug_info mmx 3dnow sse sse2  minimal-config small-config medium-config large-config full-config qt3support phonon phonon-backend accessibility opengl reduce_exports ipv6 clock-gettime clock-monotonic mremap getaddrinfo ipv6ifname getifaddrs inotify system-jpeg system-mng system-png png system-tiff system-freetype system-zlib nis cups iconv glib gstreamer dbus openssl x11sm xshape xsync xrender mitshm fontconfig xkb xmlpatterns svg webkit scripttools release
Debug ............... no
Qt 3 compatibility .. yes
QtDBus module ....... yes (run-time)
QtScriptTools module  yes
QtXmlPatterns module  yes
Phonon module ....... yes
SVG module .......... yes
WebKit module ....... yes
STL support ......... yes
PCH support ......... yes
MMX/3DNOW/SSE/SSE2..  yes/yes/yes/yes
Graphics System ..... default
IPv6 support ........ yes
IPv6 ifname support . yes
getaddrinfo support . yes
getifaddrs support .. yes
Accessibility ....... yes
NIS support ......... yes
CUPS support ........ yes
Iconv support ....... yes
Glib support ........ yes
GStreamer support ... yes
Large File support .. yes
GIF support ......... plugin
TIFF support ........ plugin (system)
JPEG support ........ plugin (system)
PNG support ......... yes (system)
MNG support ......... plugin (system)
zlib support ........ system
Session management .. yes
OpenGL support ...... yes (Desktop OpenGL)
NAS sound support ... no
XShape support ...... yes
XSync support ....... yes
Xinerama support .... runtime
Xcursor support ..... runtime
Xfixes support ...... runtime
Xrandr support ...... runtime
Xrender support ..... yes
Xi support .......... runtime
MIT-SHM support ..... yes
FontConfig support .. yes
XKB Support ......... yes
immodule support .... yes
GTK theme support ... no
MySQL support ....... plugin
PostgreSQL support .. plugin
TDS support ......... plugin
InterBase support ... plugin
SQLite support ...... plugin (qt)
OpenSSL support ..... yes (run-time)



Observe os recursos que foram habilitados, é claro que nem todos eu vou usar, aqui é só para mostrar como funciona.
Abaixo, vou listar os pacotes do Debian para habilitar os recursos listados acima. Observe que uma parte dos recursos já serão habilitados com os pacotes que são instalados junto com o Debian, os que eu vou listar foram instalados depois.
Após instalar o Debian, eu instalei o KDE, o Kdevelop, o g++, usando o Synaptic, na instalação do g++ habilitei todos os pacotes nas guias "Marcar recomendados para instalação" e "Marcar sugeridos para instalação", no Kdevelop marquei todos os recomendados e alguns sugeridos, conforme figura abaixo:

Abaixo,Synaptic aberto, mostrando Kdevelop e g++, observe no menu de contexto "Marcar sugeridos para instalação" que os que estão instalados estão apagados no menu, os que estão visíveis ainda não estão instalados.(Clique na imagem para ampliar):

>Synaptic.

Após estas etapas, ainda restam alguns pacotes Debian a serem instalados, para habilitarmos todos os recursos listados na saída do configure, abaixo, a lista com estes pacotes Debian, como já disse acima, este procedimento foi feito no Debian 5.0 lenny.

X11:
xlib ou libx11-dev e libxext-dev e x11proto-xext-dev

PostgreSql:
postgresql-dev ou postgresql-server-dev-8.3 - Para que o qt tenha acesso ao Postgre
MySql:
libmysqlclient15-dev

Phonon:
libgstreamer-plugins-base0.10-dev

JPEG:
libjpeg62-dev

TIFF - Tagged Image File Format:
libtiff4-dev

MNG - Multiple-image Network Graphics:
libmng-dev

PNG - Portable Network Graphics:
libpng12-dev

TDS - Tabular Data Stream - Para conexões TCP/IP com Sql Server e Sybase:
freetds-dev

Cups - Common UNIX Printing System:
libcups2-dev

D-Bus:
libdbus-1-dev

Opengl:
libqt4-opengl-dev

Xcursor:
libxcursor-dev

Xrandr:
libxrandr-dev

Session Management:
libsm-dev

Xinerama:
libxinerama-dev

XInput:
libxi-dev

Após a instalação destes pacotes, é só rodar o configure:

$ ./configure
$ make install

Terminada a compilação, coloque o caminho da Qt no PATH:

PATH=/usr/local/Trolltech/Qt-4.5.3/bin:$PATH
export PATH


Pagina inicial



Comentários:


Nenum comentário

Deixe seu comentário:


 *
 *

 *
  Campos marcados com * são obrigatórios.