2
qt编程时,遇到undefined reference to `vtable for xxx'怎么办
source link: https://ii74.com/post/15.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
qt编程时,遇到undefined reference to `vtable for xxx'怎么办
哎哎5年前 (2016-08-18)C++749
今天编译某个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
即可,因为新加的Q_OBJECT宏没有被moc,所以会导致,编译出错。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK