Qt-interest Archive, March 2002
qt and autotools
Message 1 in thread
Hi everybody ...
I am trying to setup an autotools environment (autoheader / automake /
autoconf - no libtool so) for a project I am working on. Now I got the
following problem. I got configure to check for the qt stuff when I try
to make the project it compiles fine (no warnings / errors) but when it
comes to linking the I get the following linker error.
main.o: In function `main':
main.o(.text+0x3d): undefined reference to
`QFOrganizer::QFOrganizer(QObject *, char const *)'
main.o(.text+0x7a): undefined reference to `QFOrganizer::newLister(QDir *)'
prefsdialog.o: In function `QFPrefsDialog::QFPrefsDialog(void)':
prefsdialog.o(.text+0x1d): undefined reference to `QFPrefsDialog virtual
table'
prefsdialog.o: In function `QFPrefsDialog::~QFPrefsDialog(void)':
prefsdialog.o(.text+0x65): undefined reference to `QFPrefsDialog virtual
table'
the lines in main.cpp where the first linker error might result from
looks like this ...
QFOrganizer* filesOrganizer= new QFOrganizer();
there's an contructor in QFOrganizer that looks like this
QFOrganizer::QFOrganizer( QObject * _parent, const char * _name)
: QObject(_parent,_name)
{
}
with the prototype
QFOrganizer( QObject* _parent= 0, const char* _name = 0);
defined in QFOrganizer.h
I don't know where the second error comes from because the class isn't
used right now not even included in any other file
but thats not the problem I am concerned about. The main problem I got
is to get autotools to add the moc dependencies to the Makefiles and
build the moc files ... Right now I put corresponding moc targets into
the Makefile.in(s) before running configure. This causes configure to
include the moc dependencies into the Makefile. It seems to work fine
but if I would change anything in configure.in or Makefile.am and run
the autotools the Makefile.in would be rewritten and the moc
dependencies would be lost. I need to add them manualy before running
configure. Is there any way to get the autotools to do this for me ???
If not is there any other way I could automate this ??? Its very time
consuming adding about 50 moc dependencies to the apropriate
Makefile.in(s) after changing anything in configure.in / Makefile.am
thanks in advance ...
--
[ signature omitted ]
Message 2 in thread
On Tue, Mar 26, 2002 at 02:21:08AM +0100, Christian Quast wrote:
> Hi everybody ...
> I am trying to setup an autotools environment (autoheader / automake /
> autoconf - no libtool so) for a project I am working on. Now I got the
> following problem. I got configure to check for the qt stuff when I try
> to make the project it compiles fine (no warnings / errors) but when it
> comes to linking the I get the following linker error.
>
> main.o: In function `main':
> main.o(.text+0x3d): undefined reference to
> `QFOrganizer::QFOrganizer(QObject *, char const *)'
> main.o(.text+0x7a): undefined reference to `QFOrganizer::newLister(QDir *)'
> prefsdialog.o: In function `QFPrefsDialog::QFPrefsDialog(void)':
> prefsdialog.o(.text+0x1d): undefined reference to `QFPrefsDialog virtual
> table'
> prefsdialog.o: In function `QFPrefsDialog::~QFPrefsDialog(void)':
> prefsdialog.o(.text+0x65): undefined reference to `QFPrefsDialog virtual
> table'
>
> the lines in main.cpp where the first linker error might result from
> looks like this ...
> QFOrganizer* filesOrganizer= new QFOrganizer();
> there's an contructor in QFOrganizer that looks like this
>
> QFOrganizer::QFOrganizer( QObject * _parent, const char * _name)
> : QObject(_parent,_name)
> {
> }
>
> with the prototype
> QFOrganizer( QObject* _parent= 0, const char* _name = 0);
> defined in QFOrganizer.h
> I don't know where the second error comes from because the class isn't
> used right now not even included in any other file
>
>
> but thats not the problem I am concerned about. The main problem I got
> is to get autotools to add the moc dependencies to the Makefiles and
> build the moc files ... Right now I put corresponding moc targets into
> the Makefile.in(s) before running configure. This causes configure to
> include the moc dependencies into the Makefile. It seems to work fine
> but if I would change anything in configure.in or Makefile.am and run
> the autotools the Makefile.in would be rewritten and the moc
> dependencies would be lost. I need to add them manualy before running
> configure. Is there any way to get the autotools to do this for me ???
> If not is there any other way I could automate this ??? Its very time
> consuming adding about 50 moc dependencies to the apropriate
> Makefile.in(s) after changing anything in configure.in / Makefile.am
The probably easiest way to get moc and friends working with
autotools is to use KDE's autotool framework. Log in into anonymous
cvs (http://www.kde.org/anoncvs.html) and check out the following
files/directories:
kde-common/admin
kdetoys/Makefile.am
kdetoys/Makefile.cvs
Copy the admin directory along with the Makefile.am and the
Makefile.cvs to your project toplevel directory. Also in your
toplevel create a configure.in.in file with just one single line of
#MIN_CONFIG
(or if you're using qt2 then #MIN_CONFIG(2.3) or whichever Qt
version you'd like to depend on)
The #MIN_CONFIG will cause the Makefile.common in the admin subdir
to copy admin/configure.in.min right into configure.in. In addition
it appends any configure.in.in's from subdirs to the final
configure.in.
Now just run make -f Makefile.cvs, which will run aclocal,
autoheader, automake, autoconf, etc. along with a tool called
am_edit. am_edit edit's the Makefile.in's and automagically adds
rules for moc. (but that's only one feature, it can do a lot more)
To get the auto-moc feature working just add a
fooapp_METASOURCES = AUTO (or libfoo_la_METASOURCES = AUTO or whatever
your target is like :)
am_edit (it used to be called automoc :) scans for _METASOURCES in
the Makefiles and generates targets to generate the moc files
mentioned there. If AUTO is listed instead then it will scan header
files and .cpp files for Q_OBJECT. If a .cpp file includes a moc
file it will automatically generate a target to generate foo.moc,
otherwise it will default to foo.moc.<yourcppsuffix> .
Hope this helps a bit.
Simon