• 6858阅读
  • 2回复

qt4头文件的问题 [复制链接]

上一主题 下一主题
离线wenyubo2008
 
只看楼主 倒序阅读 楼主  发表于: 2009-03-09
各位好心人:
我装的是qt4.3.2
我设置的环境变量是/etc/profile
PATH=/usr/local/Trolltech/Qt-4.3.4/bin:$PATH
3.              QTDIR=/usr/local/Trolltech/Qt-4.3.4
4.              MANPATH=$QTDIR/man:$MANPATH
5.              LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
6.              export PATH QTDIR MANPATH LD_LIBRARY_PATH
同样,qmake也默认为QT4的也一样,重定向链接。
1.              sudo rm /usr/bin/designer
2.              sudo ln -s /usr/local/Trolltech/Qt-4.3.4/bin/designer /usr/bin/designer
3.              sudo rm /usr/bin/qmake
4.              sudo ln -s /usr/local/Trolltech/Qt-4.3.4/bin/qmake /usr/bin/qmake
我编的程序是
#include <QApplication.h>
#include <QLable.h>
                                                                                                              
int main(int argc,char *argv[])
{
    QApplication app(argc,argv);
    QLable *label = new QLable("Hello Qt!");
    label->show();
    return app.exe();
}
编译用
qmake -project ,qmake hello.pro.之后用make
可是

[root@localhost hello]# make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../mkspecs/linux-g++ -I. -I../include/QtCore -I../include/QtCore -I../include/QtGui -I../include/QtGui -I../include -I. -I. -I.
-o hello.o hello.cpp
hello.cpp:1:26: QApplication.h: 没有那个文件或目录
hello.cpp:2:20: QLable.h: 没有那个文件或目录
hello.cpp: In function `int main(int, char**)':
hello.cpp:6: `QApplication' undeclared (first use this function)
hello.cpp:6: (Each undeclared identifier is reported only once for each
   function it appears in.)
hello.cpp:6: parse error before `(' token
hello.cpp:7: `QLable' undeclared (first use this function)
hello.cpp:7: `label' undeclared (first use this function)
hello.cpp:7: parse error before `(' token
hello.cpp:9: `app' undeclared (first use this function)
hello.cpp:5: warning: unused parameter `int argc'
hello.cpp:5: warning: unused parameter `char**argv'
make: *** [hello.o] Error 1
头文件找不到
请问兄弟们
这咋办啊



离线qioking
只看该作者 1楼 发表于: 2009-03-10
    额。。   楼主看的是那本书啊。。  学的是那个标准啊。。

  #include <QApplication>     //  里面没有 .h
    #include <QLabel>
    int main(int argc, char* argv[])
    {
        QApplication app(argc, argv);
        QLabel *label = new QLabel("Hello Qt!");
        label->show();
        return app.exec();     // 是 app.exec()  而不是 app.exe()
    }

路径方面的问题我帮不了你  。。

  我在XP下是直接装了  然后PATH 里加上 D:\Qt\bin;  的
离线wd007

只看该作者 2楼 发表于: 2009-03-10
同楼上看法
欢迎访问我的博客,一起学习提高
http://blog.csdn.net/qter_wd007
快速回复
限100 字节
 
上一个 下一个