1. 首页
  2. C++
  3. qt编程时,遇到undefined reference to `vtable for xxx'怎么办

qt编程时,遇到undefined reference to `vtable for xxx'怎么办

今天编译某个arm程序时,添加了个Q_OBJECT 的宏然后编译报错arm-none-linux-gnueabi-g++ -c -pipe -O2 -Wall&...

今天编译某个arm程序时,添加了个

Q_OBJECT 的宏

然后编译报错


arm-none-linux-gnueabi-g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/QtEmbedded-4.7.0-arm/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/QtEmbedded-4.7.0-arm/include/QtCore -I/usr/local/Trolltech/QtEmbedded-4.7.0-arm/include/QtNetwork -I/usr/local/Trolltech/QtEmbedded-4.7.0-arm/include -I. -o contrlrtu.o contrlrtu.cpp
arm-none-linux-gnueabi-g++ -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/QtEmbedded-4.7.0-arm/lib -o arm_Udp_Bind_Serial_Send main.o udpbind_con.o rcvmsgprint.o contrlrtu.o moc_udpbind_con.o moc_rcvmsgprint.o    -L/usr/local/Trolltech/QtEmbedded-4.7.0-arm/lib -lQtNetwork -L/home/develop/yizhi/GUI/tslib/installdir/lib -L/usr/local/Trolltech/QtEmbedded-4.7.0-arm/lib -lQtCore -lpthread 
contrlrtu.o: In function `ContrlRtu::ContrlRtu(QObject*)':
contrlrtu.cpp:(.text+0x1c): undefined reference to `vtable for ContrlRtu'
contrlrtu.o: In function `ContrlRtu::~ContrlRtu()':
contrlrtu.cpp:(.text+0x6c): undefined reference to `vtable for ContrlRtu'
collect2: ld returned 1 exit status
make: *** [arm_Udp_Bind_Serial_Send] 错误 1


解决方法:


make clean

qmake

make

即可,因为新加的Q_OBJECT宏没有被moc,所以会导致,编译出错。

哎哎
相关推荐