我使用的是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重新编辑 ]