[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: building a qt library

From: Craig Sanders
Subject: Re: building a qt library
Date: Fri, 28 Nov 2008 11:58:56 +1100

Greetings Lorenzo.

I have used the GNU Autotools in the past to build some simple projects which 
made use of the Qt Library. I prefer to use the GNU Autotools as I find them 
much more flexible and much more powerful than qmake.

As I recall, there are 2 key steps that need to be performed when using the GNU 
Autotools with Qt.

Step 1, You will need to get hold of an Autoconf macro which will detect if and 
if so, where you have a Qt Library installed on your system. If this macro 
detects that you have a Qt Library installed on your system, then it will 
generate some appropriate settings for you.

Step 2, You will also need to instruct the Autotools how to invoke the Qt moc 
(Meta Object Compiler) on your relevant source code files.

To accomplish the first step, you should be able to find an appropriate 
Autoconf macro here ;

Personally, I use the macro bnv_have_qt - information about which can be found 
here ;

I then call this macro from my file as is illustrated below.



# Inform aclocal and friends of where they can find additional
# local Autoconf macros.












To help illustrate how I accomplish the second step, I'll show you an example that I use - it looks as follows.


bin_PROGRAMS   = main

main_MOC_FILES = ./moc_MySignalEmitter.cpp

main_SOURCES   = ./src/main.cpp \
                 ./src/MySignalEmitter.cpp \

main_CXXFLAGS  = ${QT_CXXFLAGS} -I${srcdir}/include

main_LDFLAGS   = ${QT_LIBS}


# Inform make of how to handle C++ Header files (.hpp) that need
# to be processed by the Qt Meta Object Compiler (moc).

        @echo ""
        @echo "----------------------------------------"
        @echo "moc is creating the file : address@hidden"
        @echo "... in directory         : address@hidden/"
        @echo "... from input file      : $< "
        @echo "$<"
        @echo ""
        ${QT_MOC} -o address@hidden $<


There are 2 key aspects to this file which are worth mentioning.

The first one is the definition of the variable main_MOC_FILES. Note that the 
variable CLEANFILES is set so that make cleans up the output from the moc when 
the clean target is invoked.

The second one is the definition of the rule for running the moc on the 
relevant source code files.

I hope all of this makes sense and that you find it helpful.

- Craig Sanders

Lorenzo Bettini <address@hidden> wrote:> 
> Hi
> I'd like to build a library that uses qt,
> and I'd like to avoid qmake in favor of autotools (which I'm uses to
> now); I've heard about autoqt but it's old (and looks abandoned);
> kde-develop does not seem to have a wizard for this...
> any clue please?
> thanks in advance
>       Lorenzo
> --
> Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
> ICQ# lbetto, 16080134     (GNU/Linux User # 158233)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]