[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 ;
http://autoconf-archive.cryp.to/macros-by-category.html
Personally, I use the macro bnv_have_qt - information about which can be found
here ;
http://autoconf-archive.cryp.to/bnv_have_qt.html
I then call this macro from my configure.ac file as is illustrated below.
>>>>>
AC_INIT(
[simple_signal_emitter_autotools],
[0.0.1],
address@hidden,
[simple_signal_emitter_autotools])
# Inform aclocal and friends of where they can find additional
# local Autoconf macros.
m4_include([./m4/bnv_have_qt.m4])
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE(
[simple_signal_emitter_autotools],
[0.1])
AC_CONFIG_SRCDIR(
[./src/main.cpp])
AC_PROG_CC
AC_PROG_LIBTOOL
AC_PROG_CXX(
[${CXX}])
AC_PROG_LIBTOOL
BNV_HAVE_QT()
AC_OUTPUT([
Makefile
])
<<<<<
To help illustrate how I accomplish the second step, I'll show you an example
Makefile.am 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_MOC_FILES}
main_CXXFLAGS = ${QT_CXXFLAGS} -I${srcdir}/include
main_LDFLAGS = ${QT_LIBS}
CLEANFILES = ${main_MOC_FILES}
# Inform make of how to handle C++ Header files (.hpp) that need
# to be processed by the Qt Meta Object Compiler (moc).
.hpp.cpp:
@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)
> HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
> http://www.myspace.com/supertrouperabba
> BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
> http://www.gnu.org/software/src-highlite
> http://www.gnu.org/software/gengetopt
> http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net