0

我正在使用Qt 开发一个网络管理应用程序,我选择将Wt用于 UI,因为有了它我就不必处理任何 Web 部件(PHP、AJAX、HTML/CSS)并且它可以在所有应用程序上使用平台。

我成功地使用 cmake 编译和运行示例。虽然我习惯了 QtCreator IDE 和 qmake,但我更愿意将其用于开发和编译。

我试图在 QtCreator(qmake) 中编译“wtwithqt”示例时遇到了困难。我一直在到处寻找一些如何用 qmake 编译它的指南。但是我发现没有任何帮助。

这是我的 .pro 文件。

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

编译输出

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'

任何帮助表示赞赏!提前致谢!

4

1 回答 1

1

您的 makefile 非常合理,但我认为您忘记链接wtwitqt互操作层。添加-lwtwithqt到该LIBS行,

于 2013-02-02T12:41:10.800 回答