Qt SDK 和 Code::Blocks 的路径/配置问题
我是 Code::Blocks(不错的 IDE!)和 Qt with C++(一直在使用 PyQt,效果非常好)的新手
我有一个测试项目 - 这是代码(由 code::blocks 向导生成):
#include <QApplication>
#include <QFont>
#include <QPushButton>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QPushButton quit("Quit");
quit.resize(75, 30);
quit.setFont(QFont("Times", 18, QFont::Bold));
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
quit.show();
return app.exec();
}
我相信我在 code::blocks 中正确配置了 Qt4 的搜索路径,但是当我尝试运行此代码时,我收到下面列出的错误 - 显然我错过了一些东西 - 要么我的路径正确,要么我的安装已损坏。对于我的 Qt 安装,我使用了 Qt_SDK_Win_offline_v1_1_2_en.exe,可以在 Qt 网站上找到 - 将整个 Qt SDK 安装在 D: 中,因此 Qt 安装的根路径是 D:\QtSDK。有关
如何修复此配置的任何帮助将是感谢 - 在与 Win32s/MFC/.NET 等战斗了这么多年之后,我对使用 Qt 与 C++ 感到兴奋......
错误:
||=== QtTest,调试===|
obj\Debug\main.o||在函数“main”中:|
E:\ResourceBrowse\QtTest\main.cpp|7|对 >`imp__ZN12QApplicationC1ERiPPci'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|9|对 `imp__ZN11QPushButtonC1ERK7QStringP7QWidget' 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|12|对 `imp__ZN5QFontC1ERK7QStringiib'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|12|对 `imp__ZN7QWidget7setFontERK5QFont'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|12|对 `imp__ZN5QFontD1Ev'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|12|对 `imp__ZN5QFontD1Ev'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|14|对 `imp__Z13qFlagLocationPKc'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|14|对 `imp__Z13qFlagLocationPKc'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|14|对 `imp__ZN7QObject7connectEPKS_PKcS1_S3_N2Qt14ConnectionTypeE' 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|18|对 `imp__ZN12QApplication4execEv'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|18|对 `imp__ZN11QPushButtonD1Ev'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|18|对 `imp__ZN11QPushButtonD1Ev'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|18|对 `imp__ZN12QApplicationD1Ev'| 的未定义引用|
E:\ResourceBrowse\QtTest\main.cpp|18|对
_imp___ZN12QApplicationD1Ev'| 的未定义引用 obj\Debug\main.o||在函数中
QString':|D:\QtSDK\Desktop\Qt\4.7.3\msvc2008\include\QtCore\qstring.h|426|对
_imp___ZN7QString16fromAscii_helperEPKci'| 的未定义引用 obj\Debug\main.o||在函数中
~QString':|D:\QtSDK\Desktop\Qt\4.7.3\msvc2008\include\QtCore\qstring.h|883|对`imp__ZN7QString4freeEPNS_4DataE'的未定义引用|
obj\Debug\main.o:D:\QtSDK\Desktop\Qt\4.7.3\msvc2008\include\QtGui\qwidget.h|1001|未定义的引用 `imp__ZN7QWidget6resizeERK5QSize'|
||=== 构建完成:17 个错误,0 个警告 ===|
I'm new to Code::Blocks (nice IDE!) and to Qt with C++ (been using PyQt, which works wonderfully)
I have a test project - here's the code (generated by code::blocks wizard):
#include <QApplication>
#include <QFont>
#include <QPushButton>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QPushButton quit("Quit");
quit.resize(75, 30);
quit.setFont(QFont("Times", 18, QFont::Bold));
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
quit.show();
return app.exec();
}
I BELIEVE I have the search path for Qt4 configured correctly in code::blocks, but when I try to run this code I get the below listed errors - so obviously I'm missing something - either my paths are in correct or my installation is corrupt. For my Qt installation I used Qt_SDK_Win_offline_v1_1_2_en.exe, found on the Qt website - installed the entire Qt SDK in D:, so the root path for the Qt installation is D:\QtSDK..
Any help on how to fix this configuration would be appreciated - I am excited about using Qt with C++ after fighting with Win32s/MFC/.NET etc etc for so many years....
Errors:
||=== QtTest, Debug ===|
obj\Debug\main.o||In function `main':|
E:\ResourceBrowse\QtTest\main.cpp|7|undefined reference to >`imp__ZN12QApplicationC1ERiPPci'|
E:\ResourceBrowse\QtTest\main.cpp|9|undefined reference to `imp__ZN11QPushButtonC1ERK7QStringP7QWidget'|
E:\ResourceBrowse\QtTest\main.cpp|12|undefined reference to `imp__ZN5QFontC1ERK7QStringiib'|
E:\ResourceBrowse\QtTest\main.cpp|12|undefined reference to `imp__ZN7QWidget7setFontERK5QFont'|
E:\ResourceBrowse\QtTest\main.cpp|12|undefined reference to `imp__ZN5QFontD1Ev'|
E:\ResourceBrowse\QtTest\main.cpp|12|undefined reference to `imp__ZN5QFontD1Ev'|
E:\ResourceBrowse\QtTest\main.cpp|14|undefined reference to `imp__Z13qFlagLocationPKc'|
E:\ResourceBrowse\QtTest\main.cpp|14|undefined reference to `imp__Z13qFlagLocationPKc'|
E:\ResourceBrowse\QtTest\main.cpp|14|undefined reference to `imp__ZN7QObject7connectEPKS_PKcS1_S3_N2Qt14ConnectionTypeE'|
E:\ResourceBrowse\QtTest\main.cpp|18|undefined reference to `imp__ZN12QApplication4execEv'|
E:\ResourceBrowse\QtTest\main.cpp|18|undefined reference to `imp__ZN11QPushButtonD1Ev'|
E:\ResourceBrowse\QtTest\main.cpp|18|undefined reference to `imp__ZN11QPushButtonD1Ev'|
E:\ResourceBrowse\QtTest\main.cpp|18|undefined reference to `imp__ZN12QApplicationD1Ev'|
E:\ResourceBrowse\QtTest\main.cpp|18|undefined reference to
_imp___ZN12QApplicationD1Ev'|
QString':|
obj\Debug\main.o||In functionD:\QtSDK\Desktop\Qt\4.7.3\msvc2008\include\QtCore\qstring.h|426|undefined reference to
_imp___ZN7QString16fromAscii_helperEPKci'|
~QString':|
obj\Debug\main.o||In functionD:\QtSDK\Desktop\Qt\4.7.3\msvc2008\include\QtCore\qstring.h|883|undefined reference to `imp__ZN7QString4freeEPNS_4DataE'|
obj\Debug\main.o:D:\QtSDK\Desktop\Qt\4.7.3\msvc2008\include\QtGui\qwidget.h|1001|undefined reference to
`imp__ZN7QWidget6resizeERK5QSize'|||=== Build finished: 17 errors, 0 warnings ===|
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论