• 8509阅读
  • 5回复

使用 qt _ dev_c++ 编译时有如下错误.请大家指点 [复制链接]

上一主题 下一主题
离线liur
 
只看楼主 倒序阅读 楼主  发表于: 2007-08-01
— 本帖被 XChinux 从 Qt for Linux/X11 移动到本区(2010-02-08) —
[Linker error] undefined reference to `_imp___ZN12QApplicationC1ERiPPci'
[Linker error] undefined reference to `_imp___ZN6QLabelC1ERK7QStringP7QWidget6QFlagsIN2Qt10WindowTypeEE'
[Linker error] undefined reference to `_imp___ZN12QApplication4execEv'
[Linker error] undefined reference to `QApplication::~QApplication()'
[Linker error] undefined reference to `QApplication::~QApplication()'
[Linker error] undefined reference to `_imp___ZN7QString4freeEPNS_4DataE'
[Linker error] undefined reference to `_imp___ZN7QString16fromAscii_helperEPKci'
ld returned 1 exit status

上面是编译时候报的错误.我使用的是:
qt-win-opensource-4.2.3-mingw.exe + devcpp-4.9.9.2_setup.exe
已经进行了 build debug library. 并在 Dev_C++ 中进行了 Qt 的一些相关设置.

如果我使用 Qt 4.2.3 Command Prompt 进行编译的话,居然提示:
g++    Hello.cpp  -o Hello
Hello.cpp:1:24: QApplication: No such file or directory
Hello.cpp:2:18: QLabel: No such file or directory
Hello.cpp: In function `int main(int, char**)':
Hello.cpp:6: error: `QApplication' undeclared (first use this function)
Hello.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)
Hello.cpp:6: error: expected `;' before "app"
Hello.cpp:7: error: `QLabel' undeclared (first use this function)
Hello.cpp:7: error: `label' undeclared (first use this function)
Hello.cpp:7: error: `QLabel' has not been declared
Hello.cpp:10: error: `app' undeclared (first use this function)

我已经进行了环境变量设置了.是不是我的环境变量设置有问题呢? 还请大家指点一二.
谢谢先.
离线liur
只看该作者 1楼 发表于: 2007-08-01
我将程序代码放倒了 C:\Qt\4.2.3\ 下编译居然通过了~!!!
这叫我很诧异.难道每次编译的时候也要设置一下当前的路径为编译环境吗? 就如论坛里有达人提出的 <<一句话进行QT编译>>(名字记不清楚了)里介绍的那样.

Qt 编译就是这么麻烦吗?

我晕了...而且是彻底的晕了....
离线XChinux

只看该作者 2楼 发表于: 2007-08-01
主要是因为环境变量的问题吧。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线liur
只看该作者 3楼 发表于: 2007-08-02
to xchinux:
我也认为是环境变量设置的问题.

我的开发环境如下:
1. qt 安装在 C:\Qt\4.2.3
2. dev-c++ 安装在 C:\Dev-Cpp
3. dev-c++ 环境设置如下:
    在 工具->编译选项->目录 这个选项下:
        在 <二进制>下加入 C:\Qt\4.2.3\bin ;
        在 <库> 下加入C:\Qt\4.2.3\lib;
        在 <c包含文件> 下加入 C:\Qt\4.2.3\include; C:\Qt\4.2.3\include\Qt; C:\Qt\4.2.3\include\QtGui;  C:\Qt\4.2.3\include\QtCore;
        在 <C++包含文件> 下加入 C:\Qt\4.2.3\include; C:\Qt\4.2.3\include\Qt; C:\Qt\4.2.3\include\QtGui;  C:\Qt\4.2.3\include\QtCore; C:\Qt\4.2.3\include\ActiveQt
4. 环境变量设置:
    a. 在用户变量的<include>中加入: C:\Qt\4.2.3\include
    b. 在用户变量的<lib>中加入: C:\Qt\4.2.3\lib
    c. 在用户变量的<path>中加入: C:\Qt\4.2.3\bin
    d. 在用户变量中添加了 <QMAKESPEC>变量,设置其值 : win32-g++
    e. 在系统变量的<Path>中加入: C:\Dev-Cpp\bin;C:\Dev-Cpp\mingw32\bin;C:\Qt\4.2.3\bin
    f. 在系统变量中添加了 <QTDIR>变量,设置其值 : C:\Qt\4.2.3

以上就是我的全部设置了.请大家指正错误的地方.再次谢谢先.
[ 此贴被liur在2007-08-02 10:39重新编辑 ]
离线XChinux

只看该作者 4楼 发表于: 2007-08-02
moc相关设置呢?

建议使用Qt Integration with VS.NET 200X or Eclipse
要不然直接使用qmake生成.pro文件,然后自己再修改.pro以适合自己的应用,手工make来编译,这样自己清清楚楚的。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线hike
只看该作者 5楼 发表于: 2008-03-20
我也遇到同样的问题了。
那是链接是找不到库

在工程属性里的 参数 里的 linker添加 
./Qt/4.3.3/lib/libQtGui4.a
../Qt/4.3.3/lib/libQtCore4.a

也可以把lib下的所有填进来也可以
快速回复
限100 字节
 
上一个 下一个