• 7064阅读
  • 1回复

qt编译错误解决方法(仅供新手借鉴) [复制链接]

上一主题 下一主题
离线iloveyouxxx
 
只看楼主 倒序阅读 楼主  发表于: 2007-01-09
我使用的是QT/E 2.3.7 现在先在QT/E for x86下编译程序
tmake-1.11

编译tutorial/t1里的简单HELLO程序就有错误出现

程序:
#include <qapplication.h>
#include <qpushbutton.h>

int main( int argc, char **argv)
{
QApplication a(argc, argv);

QPushButton hello("Hello,world!", 0);
hello.resize(240,320);

a.setMainWidget(&hello);
hello.show();
return a.exec();
}

错误信息:
[root@localhost bin]# make
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/friendly-arm/x86-

qtopia/qt/include -o t1.o t1.cpp
gcc -o hello t1.o -L/friendly-arm/x86-qtopia/qt b -lqte
/friendly-arm/x86-qtopia/qt b bqte.so: undefined reference to `operator new[](unsigned)'
/friendly-arm/x86-qtopia/qt b bqte.so: undefined reference to `operator delete(void*)'
/friendly-arm/x86-qtopia/qt b bqte.so: undefined reference to `cos'
/friendly-arm/x86-qtopia/qt b bqte.so: undefined reference to `sin'
/friendly-arm/x86-qtopia/qt b bqte.so: undefined reference to `__cxa_pure_virtual'
/friendly-arm/x86-qtopia/qt b bqte.so: undefined reference to `pow'
/friendly-arm/x86-qtopia/qt b bqte.so: undefined reference to `operator delete[](void*)'
/friendly-arm/x86-qtopia/qt b bqte.so: undefined reference to `operator new(unsigned)'
collect2: ld returned 1 exit status
make: *** [hello] Error 1

原因是链接用的gcc命令不对应该用g++

应该修改Makefile文件
将"SYSCONF_LINK=gcc" 改为 "SYSCONF=g++"

另外一劳永逸的方法:
修改tmake的配置文件,tmake.conf(具体路径视自己机器而定,x86下一般为tmake/lib/qws/linux-

generic-g++/tmake.conf)
将tmake.conf中的“TMAKE_LINK=gcc”改为“TMAKE_LINK=g++”
[ 此贴被XChinux在2007-01-09 11:14重新编辑 ]
离线shiroki

只看该作者 1楼 发表于: 2007-01-12
这个问题真是挺奇怪的,好像经常有人碰到。。可是我从来没碰到过哦
--
shiro is White
ki is tree
http://www.cuteqt.com
论坛 http://www.cuteqt.com/bbs
博客 http://www.cuteqt.com/blog
博客镜像: http://sites.cuteqt.com/cuteqt
Linux/Qt/嵌入式讨论群 http://qun.qq.com/air/5699823
快速回复
限100 字节
 
上一个 下一个