标题:qt编译错误解决方法(仅供新手借鉴)
作者:iloveyouxxx
日期:2007-01-09 09:24
内容:
我使用的是QT/E 2.3.7 现在先在QT/E for x86下编译程序
tmake-1.11
编译tutorial/t1里的简单HELLO程序就有错误出现
程序:
#include
#include
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();
}
错误信息:
# 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: *** 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++”
#1 [shiroki 01-12 20:37]
这个问题真是挺奇怪的,好像经常有人碰到。。可是我从来没碰到过哦