• 4759阅读
  • 1回复

用arm-linux-g++连接QThread派生的程序,出现错提示undefined reference to `typeinfo for QThread' [复制链接]

上一主题 下一主题
离线cwby
 
只看楼主 倒序阅读 楼主  发表于: 2009-02-12
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
用arm-linux-g++连接QThread派生的程序,出现错提示:

arm-linux-g++  -o h main.o SockMsgThread.o  -L/qt_build/qt-2.3.7/lib -L/usr/X11R6/lib -lqte-mt  -lm -lpthread
SockMsgThread.o(.gnu.linkonce.r._ZTI14CSockMsgThread+0x8):/mnt/hgfs/dellus/temp/SockMsgThread.cpp:6: undefined reference to `typeinfo for QThread'
/qt_build/qt-2.3.7/lib/libqte-mt.so: undefined reference to `QListBox::returnPressed(QListBoxItem*)'
/qt_build/qt-2.3.7/lib/libqte-mt.so: undefined reference to `QPopupMenu::activatedRedirect(int)'
/qt_build/qt-2.3.7/lib/libqte-mt.so: undefined reference to `QMainWindow::toolBarPositionChanged(QToolBar*)'
/qt_build/qt-2.3.7/lib/libqte-mt.so: undefined reference to `QIconView::currentChanged(QIconViewItem*)'
/qt_build/qt-2.3.7/lib/libqte-mt.so: undefined reference to `vtable for QAuServer'
/qt_build/qt-2.3.7/lib/libqte-mt.so: undefined reference to `QLCDNumber::overflow()'
/qt_build/qt-2.3.7/lib/libqte-mt.so: undefined reference to `vtable for QServerSocket'
/qt_build/qt-2.3.7/lib/libqte-mt.so: undefined reference to `QListBox::mouseButtonPressed(int, QListBoxItem*, QPoint const&)'
....

以下为简化了的源码:

==============================================
//SockMsgThread.h
#ifndef SockMsgThread_h
#define SockMsgThread_h
#include <qthread.h>
//#include <qobject.h>
//#include <qevent.h>
//#include <qvalidator.h>
typedef unsigned int UINT;
class CSockMsgEvent : public QCustomEvent //Óû§×Ô¶¨ÒåµÄʼþÀà
{
public:
CSockMsgEvent() : QCustomEvent(id_SockMsgEvent) { ; }

};
//*/

class CSockMsgThread :  public QThread//, public QObject
{
//Q_OBJECT
public:
CSockMsgThread();
~CSockMsgThread(){}
//protected:
virtual void run();

};


#endif//SockMsgThread_h

------------------------------------------------
//SockMsgThread.cpp


CSockMsgThread::CSockMsgThread()
{
}
void CSockMsgThread::run()
{

}
---------------------------------------
#include <qapplication.h>
#include "SockMsgThread.h"
int main(int argc , char**argv)
{
QApplication a(argc, argv);
CSockMsgThread thread;
thread.start();
return a.exec();
}

-------------------------
h.pro
SOURCES += main.cpp \
SockMsgThread.cpp
HEADERS += SockMsgThread.h

QT += network
TEMPLATE =app
CONFIG += thread qt warn_on release 
LANGUAGE = C++

---------------------------------------------------------------
makefile用qmake生成:
#############################################################################
# Makefile for building: h
# Generated by qmake (1.05a) (Qt 3.1.2) on: Fri Feb  6 20:04:08 2009
# Project:  h.pro
# Template: app
# Command: $(QMAKE) -o Makefile h.pro
#############################################################################

####### Compiler, tools and options
CC      = arm-linux-gcc
CXX      = arm-linux-g++
LEX      = flex
YACC    = yacc
CFLAGS  = -pipe -Wall -W -O2 -g -pipe  -fno-use-cxa-atexit -fno-exceptions -D_REENTRANT  -DQT_NO_DEBUG -DQT_THREAD_SUPPORT
CXXFLAGS = -pipe -Wall -W -O2 -g -pipe  -fno-use-cxa-atexit -fno-exceptions -D_REENTRANT  -DQT_NO_DEBUG -DQT_THREAD_SUPPORT
LEXFLAGS =
YACCFLAGS= -d
INCPATH  = -I/usr/lib/qt-3.1/mkspecs/default -I. -I$(QTDIR)/include
LINK    = arm-linux-g++
LFLAGS  =
LIBS    = $(SUBLIBS) -L$(QTDIR)/lib -L/usr/X11R6/lib -lqte-mt  -lm -lpthread
AR      = ar cqs
RANLIB  =
MOC      = $(QTDIR)/bin/moc
UIC      = $(QTDIR)/bin/uic
QMAKE    = qmake
TAR      = tar -cf
GZIP    = gzip -9f
COPY    = cp -f
COPY_FILE= $(COPY) -p
COPY_DIR = $(COPY) -pR
DEL_FILE = rm -f
SYMLINK  = ln -sf
DEL_DIR  = rmdir
MOVE    = mv -f
CHK_DIR_EXISTS= test -d
MKDIR    = mkdir -p

####### Output directory

OBJECTS_DIR = ./

####### Files

HEADERS = SockMsgThread.h
SOURCES = main.cpp \
SockMsgThread.cpp
OBJECTS = main.o \
SockMsgThread.o
FORMS =
UICDECLS =
UICIMPLS =
SRCMOC  =
OBJMOC =
DIST  = h.pro
QMAKE_TARGET = h
DESTDIR  =
TARGET  = h

first: all
####### Implicit rules

.SUFFIXES: .c .cpp .cc .cxx .C

.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $ <

.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $ <

.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $ <

.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $ <

.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $ <

####### Build rules

all: Makefile $(TARGET)

$(TARGET):  $(UICDECLS) $(OBJECTS) $(OBJMOC)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)

mocables: $(SRCMOC)

$(MOC):
( cd $(QTDIR)/src/moc ; $(MAKE) )

Makefile: h.pro  /usr/lib/qt-3.1/mkspecs/default/qmake.conf
$(QMAKE) -o Makefile h.pro
qmake:
@$(QMAKE) -o Makefile h.pro

dist:
@mkdir -p .tmp/h && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .tmp/h/ && ( cd `dirname .tmp/h` && $(TAR) h.tar h && $(GZIP) h.tar ) && $(MOVE) `dirname .tmp/h`/h.tar.gz . && $(DEL_FILE) -r .tmp/h

mocclean:

uiclean:

yaccclean:
lexclean:
clean:
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
-$(DEL_FILE) $(TARGET) $(TARGET)


FORCE:

####### Compile

main.o: main.cpp SockMsgThread.h

SockMsgThread.o: SockMsgThread.cpp SockMsgThread.h

####### Install

install: all

uninstall:
离线blancyang

只看该作者 1楼 发表于: 04-16
楼主最后解决问题了嘛
快速回复
限100 字节
 
上一个 下一个