bonjour,

j'ai vu sur un site que l'on peux utiliser les autotools avec Qt grâce à la macro m4 AX_HAVE_QT
le fichier m4 ax_have_qt.m4 est le suivant
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
 
# ===========================================================================
#        http://www.gnu.org/software/autoconf-archive/ax_have_qt.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_HAVE_QT
#
# DESCRIPTION
#
#   Searches $PATH and queries qmake for Qt include files, libraries and Qt
#   binary utilities. The macro only supports Qt5 or later.
#
#   The following shell variable is set to either "yes" or "no":
#
#     have_qt
#
#   Additionally, the following variables are exported:
#
#     QT_CXXFLAGS
#     QT_LIBS
#     QT_MOC
#     QT_UIC
#     QT_LRELEASE
#     QT_LUPDATE
#     QT_DIR
#
#   which respectively contain an "-I" flag pointing to the Qt include
#   directory, link flags necessary to link with Qt and X, the full path to
#   the meta object compiler and the user interface compiler both, and
#   finally the variable QTDIR as Qt likes to see it defined.
#
#   Example lines for Makefile.in:
#
#     CXXFLAGS = @QT_CXXFLAGS@
#     MOC      = @QT_MOC@
#
#   After the variables have been set, a trial compile and link is performed
#   to check the correct functioning of the meta object compiler. This test
#   may fail when the different detected elements stem from different
#   releases of the Qt framework. In that case, an error message is emitted
#   and configure stops.
#
#   No common variables such as $LIBS or $CFLAGS are polluted.
#
# LICENSE
#
#   Copyright (c) 2008 Bastiaan Veelo <Bastiaan@Veelo.net>
#   Copyright (c) 2014 Alex Henrie <alexhenrie24@gmail.com>
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved. This file is offered as-is, without any
#   warranty.
 
#serial 12
 
AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT])
AC_DEFUN([AX_HAVE_QT],
[
  AC_REQUIRE([AC_PROG_CXX])
  AC_REQUIRE([AC_PATH_X])
  AC_REQUIRE([AC_PATH_XTRA])
 
  AC_MSG_CHECKING(for Qt)
  # If we have Qt5 or later in the path, we're golden
  ver=`qmake --version | grep -o "Qt version ."`
  if test "$ver" ">" "Qt version 4"; then
    have_qt=yes
    # This pro file dumps qmake's variables, but it only works on Qt 5 or later
    am_have_qt_pro=`mktemp`
    am_have_qt_makefile=`mktemp`
    # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt
    cat > $am_have_qt_pro << EOF
qtHaveModule(axcontainer):       QT += axcontainer
qtHaveModule(axserver):          QT += axserver
qtHaveModule(concurrent):        QT += concurrent
qtHaveModule(core):              QT += core
qtHaveModule(dbus):              QT += dbus
qtHaveModule(declarative):       QT += declarative
qtHaveModule(designer):          QT += designer
qtHaveModule(gui):               QT += gui
qtHaveModule(help):              QT += help
qtHaveModule(multimedia):        QT += multimedia
qtHaveModule(multimediawidgets): QT += multimediawidgets
qtHaveModule(network):           QT += network
qtHaveModule(opengl):            QT += opengl
qtHaveModule(printsupport):      QT += printsupport
qtHaveModule(qml):               QT += qml
qtHaveModule(qmltest):           QT += qmltest
qtHaveModule(x11extras):         QT += x11extras
qtHaveModule(script):            QT += script
qtHaveModule(scripttools):       QT += scripttools
qtHaveModule(sensors):           QT += sensors
qtHaveModule(serialport):        QT += serialport
qtHaveModule(sql):               QT += sql
qtHaveModule(svg):               QT += svg
qtHaveModule(testlib):           QT += testlib
qtHaveModule(uitools):           QT += uitools
qtHaveModule(webkit):            QT += webkit
qtHaveModule(webkitwidgets):     QT += webkitwidgets
qtHaveModule(xml):               QT += xml
qtHaveModule(xmlpatterns):       QT += xmlpatterns
percent.target = %
percent.commands = @echo -n "\$(\$(@))\ "
QMAKE_EXTRA_TARGETS += percent
EOF
    qmake $am_have_qt_pro -o $am_have_qt_makefile
    QT_CXXFLAGS=`make -f $am_have_qt_makefile CXXFLAGS INCPATH`
    QT_LIBS=`make -f $am_have_qt_makefile LIBS`
    rm $am_have_qt_pro $am_have_qt_makefile
 
    # Look for specific tools in $PATH
    QT_MOC=`which moc`
    QT_UIC=`which uic`
    QT_LRELEASE=`which lrelease`
    QT_LUPDATE=`which lupdate`
 
    # Get Qt version from qmake
    QT_DIR=`qmake --version | grep -o -E /.+`
 
    # All variables are defined, report the result
    AC_MSG_RESULT([$have_qt:
    QT_CXXFLAGS=$QT_CXXFLAGS
    QT_DIR=$QT_DIR
    QT_LIBS=$QT_LIBS
    QT_UIC=$QT_UIC
    QT_MOC=$QT_MOC
    QT_LRELEASE=$QT_LRELEASE
    QT_LUPDATE=$QT_LUPDATE])
  else
    # Qt was not found
    have_qt=no
    QT_CXXFLAGS=
    QT_DIR=
    QT_LIBS=
    QT_UIC=
    QT_MOC=
    QT_LRELEASE=
    QT_LUPDATE=
    AC_MSG_RESULT($have_qt)
  fi
  AC_SUBST(QT_CXXFLAGS)
  AC_SUBST(QT_DIR)
  AC_SUBST(QT_LIBS)
  AC_SUBST(QT_UIC)
  AC_SUBST(QT_MOC)
  AC_SUBST(QT_LRELEASE)
  AC_SUBST(QT_LUPDATE)
 
  #### Being paranoid:
  if test x"$have_qt" = xyes; then
    AC_MSG_CHECKING(correct functioning of Qt installation)
    AC_CACHE_VAL(ax_cv_qt_test_result,
    [
      cat > ax_qt_test.h << EOF
#include <qobject.h>
class Test : public QObject
{
Q_OBJECT
public:
  Test() {}
  ~Test() {}
public slots:
  void receive() {}
signals:
  void send();
};
EOF
 
      cat > ax_qt_main.$ac_ext << EOF
#include "ax_qt_test.h"
#include <qapplication.h>
int main( int argc, char **argv )
{
  QApplication app( argc, argv );
  Test t;
  QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) );
}
EOF
 
      ax_cv_qt_test_result="failure"
      ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
      AC_TRY_EVAL(ax_try_1)
      if test x"$ac_status" != x0; then
        echo "$ax_err_1" >&AS_MESSAGE_LOG_FD
        echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD
        cat ax_qt_test.h >&AS_MESSAGE_LOG_FD
      else
        ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
        AC_TRY_EVAL(ax_try_2)
        if test x"$ac_status" != x0; then
          echo "$ax_err_2" >&AS_MESSAGE_LOG_FD
          echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
          cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD
        else
          ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null"
          AC_TRY_EVAL(ax_try_3)
          if test x"$ac_status" != x0; then
            echo "$ax_err_3" >&AS_MESSAGE_LOG_FD
            echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
            cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD
          else
            ax_try_4="$CXX -o ax_qt_main ax_qt_main.o moc_ax_qt_test.o $QT_LIBS $LIBS >/dev/null 2>/dev/null"
            AC_TRY_EVAL(ax_try_4)
            if test x"$ac_status" != x0; then
              echo "$ax_err_4" >&AS_MESSAGE_LOG_FD
            else
              ax_cv_qt_test_result="success"
            fi
          fi
        fi
      fi
    ])dnl AC_CACHE_VAL ax_cv_qt_test_result
    AC_MSG_RESULT([$ax_cv_qt_test_result])
    if test x"$ax_cv_qt_test_result" = "xfailure"; then
      AC_MSG_ERROR([Failed to find matching components of a complete
                  Qt installation. Try using more options,
                  see ./configure --help.])
    fi
 
    rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \
          ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main
  fi
])
j'ai d'abord copié ce fichier dans /usr/share/autoconf/autoconf/, /usr/share/aclocal-1.14/ et /usr/share/aclocal/

voici mon configure.ac
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
 
AC_PREREQ([2.69])
AC_INIT([hello], [1.0], [matser@free.fr])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/main.cc])
AM_CONFIG_HEADER([config.h])
 
# Checks for programs.
AC_PROG_CXX
 
# Checks for libraries.
AX_HAVE_QT
# Checks for header files.
 
# Checks for typedefs, structures, and compiler characteristics.
 
# Checks for library functions.
 
AC_OUTPUT(Makefile src/Makefile)
voici Makefile.am:
mon src/Makefile
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
bin_PROGRAMS = hello
hello_SOURCES = main.cc
mon main.cc:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
#include <QApplication>
#include <QLabel>
 
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QLabel *label = new QLabel("Hello Qt!");
    label->show();
    return app.exec();
}
les commandes aclocal,autoheader et automake fonctionnent correctement:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
$ touch NEWS AUTHORS README ChangeLog
$ aclocal
$ autoheader
$ automake -c -a
$ autoconf
avant de faire ./configure:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
$ have_qt=yes
$ export  QT_CXXFLAGS;export  QT_LIBS;export  QT_MOC;export  QT_UIC;export  QT_LRELEASE;export  QT_LUPDATE;export  QT_DIR
la sortie de ./configure
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for X... libraries , headers 
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for Qt... yes:
    QT_CXXFLAGS=-pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_XML_LIB -DQT_TESTLIB_LIB -DQT_SQL_LIB -DQT_NETWORK_LIB -DQT_DBUS_LIB -DQT_CONCURRENT_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR="/tmp" -I/usr/lib/i386-linux-gnu/qt5/mkspecs/linux-g++ -I. -isystem /usr/include/i386-linux-gnu/qt5 -isystem /usr/include/i386-linux-gnu/qt5/QtPrintSupport -isystem /usr/include/i386-linux-gnu/qt5/QtOpenGL -isystem /usr/include/i386-linux-gnu/qt5/QtWidgets -isystem /usr/include/i386-linux-gnu/qt5/QtXml -isystem /usr/include/i386-linux-gnu/qt5/QtTest -isystem /usr/include/i386-linux-gnu/qt5/QtSql -isystem /usr/include/i386-linux-gnu/qt5/QtNetwork -isystem /usr/include/i386-linux-gnu/qt5/QtDBus -isystem /usr/include/i386-linux-gnu/qt5/QtConcurrent -isystem /usr/include/i386-linux-gnu/qt5/QtGui -isystem /usr/include/i386-linux-gnu/qt5/QtCore -I. 
    QT_DIR=/usr/lib/i386-linux-gnu
    QT_LIBS=-lQt5PrintSupport -lQt5OpenGL -lQt5Widgets -lQt5Xml -lQt5Test -lQt5Sql -lQt5Network -lQt5DBus -lQt5Concurrent -lQt5Gui -lQt5Core -lGL -lpthread  
    QT_UIC=/usr/bin/uic
    QT_MOC=/usr/bin/moc
    QT_LRELEASE=/usr/bin/lrelease
    QT_LUPDATE=/usr/bin/lupdate
checking correct functioning of Qt installation... success
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
le problème se fait avec make:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ make
make  all-recursive
make[1]: Entering directory '/home/matser/qt5/hello-1.0'
Making all in src
make[2]: Entering directory '/home/matser/qt5/hello-1.0/src'
g++ -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cc
main.cc:1:24: fatal error: QApplication: Aucun fichier ou dossier de ce type
 #include <QApplication>
                        ^
compilation terminated.
Makefile:344: recipe for target 'main.o' failed
make[2]: *** [main.o] Error 1
make[2]: Leaving directory '/home/matser/qt5/hello-1.0/src'
Makefile:356: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/matser/qt5/hello-1.0'
Makefile:296: recipe for target 'all' failed
make: *** [all] Error 2
le fichier QApplication est ici:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
$ find / -name QApplication 2>/dev/null
/usr/include/qt4/QtGui/QApplication
/usr/include/i386-linux-gnu/qt5/QtWidgets/QApplication
/opt/Qt/5.5/android_armv7/include/QtWidgets/QApplication
/opt/Qt/5.5/Src/qtbase/include/QtWidgets/QApplication
/opt/Qt/5.5/gcc/include/QtWidgets/QApplication
qu'ai-je oublié de faire?

quelqu'un a une idée?