PDA

View Full Version : Qt3: How to include/link 3rd party libraries without moc? [solved]



EnQ
30th September 2007, 21:16
I just started trying to write a little tool that needs to catch global shortcuts. As far as I understood this should be possible using kdelibs (kaccel.h). I include kaccel.h and append /usr/kde/3.5/include/ to INCLUDEPATH in my project file. Then I run qmake and make and come up with the following error:

i686-pc-linux-gnu-g++ -c -pipe -Wall -W -O2 -march=athlon-xp -pipe -fno-strict-aliasing -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT -I/usr/qt/3/mkspecs/linux-g++ -I. -I. -I/usr/kde/3.5/include -I/usr/qt/3/include -o main.o main.cpp
main.cpp:3: warning: unused parameter 'parent'
main.cpp:3: warning: unused parameter 'name'
/usr/qt/3/bin/moc main.h -o moc_main.cpp
i686-pc-linux-gnu-g++ -c -pipe -Wall -W -O2 -march=athlon-xp -pipe -fno-strict-aliasing -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT -I/usr/qt/3/mkspecs/linux-g++ -I. -I. -I/usr/kde/3.5/include -I/usr/qt/3/include -o moc_main.o moc_main.cpp
/usr/qt/3/bin/moc /usr/kde/3.5/include/kaccel.h -o /usr/kde/3.5/include/moc_kaccel.cpp
moc: Cannot create /usr/kde/3.5/include/moc_kaccel.cpp
make: *** [/usr/kde/3.5/include/moc_kaccel.cpp] Error 1

Seems like moc tries to run on kdelibs. kaccel.h unfortunately uses the Q_OBJECT macro, so moc is correct on its decision. However, I have that library already compiled and don't need it a second time. How do I tell qmake/make not to compile kaccel again? Or at least to compile it somewhere else instead of /usr/kde/... ? Does it have to be recompiled (I don't think so)?

I didn't code in C++/Qt for 1 1/2 year and never before and Google doesn't get me any answer to my problem. Could someone please give me a short example on how to include 3rd party libraries (doesn't need to be KDE). I assume it's rather simple to solve?

If it matters: I use GCC 4.1.2, Qt 3.3.8 and KDE 3.5.5.

Thanks in advance!

jacek
30th September 2007, 22:02
Are you sure you didn't add kaccel.h to HEADERS by accident? Don't forget to add KDE libraries to LIBS variable too.

EnQ
30th September 2007, 22:23
Not me, but qmake -project. Thanks! :o