Compiling wtwithqt example with QtCreator(qmake)-Collection of common programming errors

I am working on a network management application with Qt and I chose to use Wt for UI, because with it I will not have to deal with any of web parts (PHP, AJAX, HTML/CSS) and it’ll be usable on all platforms.

I successfully managed to compile and run examples using cmake. Although I am used to QtCreator IDE and qmake I would rather use that for development and compiling.

I got stuck trying to compile “wtwithqt” example in QtCreator(qmake). I’ve been searching everywhere for some guide how to compile it with qmake. However I found nothing helpful.

Here is my .pro file.

testWt.pro

QT += core
QT -= gui

TARGET = helloqt
CONFIG += console no_keywords
CONFIG -=app_bundle

TEMPLATE = app

INCLUDEPATH += lib

LIBS += -lwt -lwthttp -lboost_signals -lboost_system -lboost_regex

QMAKE_CXXFLAGS += -DNDEBUG

HEADERS += \
    QtObject.h \
    HelloApplication.h

SOURCES += \
    hello.cpp \
    QtObject.cpp

Compile ouput

13:28:15: Running build steps for project testWt...
13:28:15: Starting: "/usr/bin/make" clean -w
make: Entering directory `/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug'
/usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug CONFIG+=declarative_debug -o Makefile ../testWt/testWt.pro
make: Leaving directory `/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug'
make: Entering directory `/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug'
rm -f moc_QtObject.cpp
rm -f hello.o QtObject.o moc_QtObject.o
rm -f *~ core *.core
make: Leaving directory `/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug'
13:28:15: The process "/usr/bin/make" exited normally.
13:28:15: Configuration unchanged, skipping qmake step.
13:28:15: Starting: "/usr/bin/make" -w
make: Entering directory `/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug'
g++ -c -pipe -DNDEBUG -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_KEYWORDS -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../testWt -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I../testWt/lib -I. -I../testWt -I. -o hello.o ../testWt/hello.cpp
g++ -c -pipe -DNDEBUG -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_KEYWORDS -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../testWt -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I../testWt/lib -I. -I../testWt -I. -o QtObject.o ../testWt/QtObject.cpp
/usr/bin/moc-qt4 -DQT_WEBKIT -DQT_NO_KEYWORDS -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../testWt -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I../testWt/lib -I. -I../testWt -I. ../testWt/QtObject.h -o moc_QtObject.cpp
g++ -c -pipe -DNDEBUG -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_KEYWORDS -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../testWt -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I../testWt/lib -I. -I../testWt -I. -o moc_QtObject.o moc_QtObject.cpp
g++  -o helloqt hello.o QtObject.o moc_QtObject.o    -L/usr/lib/i386-linux-gnu -lwt -lwthttp -lboost_signals -lboost_system -lboost_regex -lQtCore -lpthread 
hello.o: In function `HelloApplication':
/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug/../testWt/hello.cpp:43: undefined reference to `Wt::WQApplication::WQApplication(Wt::WEnvironment const&, bool)'
hello.o: In function `HelloApplication::propagateGreet()':
/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug/../testWt/hello.cpp:87: undefined reference to `Wt::toQString(Wt::WString const&)'
hello.o: In function `HelloApplication::doGreet(QString const&)':
/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug/../testWt/hello.cpp:92: undefined reference to `Wt::toWString(QString const&)'
hello.o: In function `~WQApplication':
/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug/../testWt/lib/WQApplication:82: undefined reference to `vtable for Wt::WQApplication'
hello.o:(.rodata._ZTV16HelloApplication[vtable for HelloApplication]+0x3c): undefined reference to `Wt::WQApplication::initialize()'
hello.o:(.rodata._ZTV16HelloApplication[vtable for HelloApplication]+0x40): undefined reference to `Wt::WQApplication::finalize()'
hello.o:(.rodata._ZTV16HelloApplication[vtable for HelloApplication]+0x44): undefined reference to `Wt::WQApplication::notify(Wt::WEvent const&)'
hello.o:(.rodata._ZTV16HelloApplication[vtable for HelloApplication]+0x5c): undefined reference to `Wt::WQApplication::realNotify(Wt::WEvent const&)'
hello.o:(.rodata._ZTI16HelloApplication[typeinfo for HelloApplication]+0x8): undefined reference to `typeinfo for Wt::WQApplication'
collect2: ld returned 1 exit status
make: Leaving directory `/home/nms-development/QtProject/testWt-build-desktop-Qt_4_8_1_in_PATH__System__Debug'
make: *** [helloqt] Error 1
13:28:28: The process "/usr/bin/make" exited with code 2.
Error while building project testWt (target: Desktop)
When executing build step 'Make'

Any help is appreciated! Thanks in advance!

  1. Your makefile is pretty much sound, but I think you’ve forgotten to link the wtwitqt interop layer. Add -lwtwithqt to the LIBS line,

Originally posted 2013-11-09 23:06:58.