刘志华 发表于 2012-3-22 21:41:11

根据手册执行第一个Qt时出现问题

# make
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/include -o first.o first.cpp
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/include -o main.o main.cpp
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/include -o moc_first.o moc_first.cpp
g++-o /opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/image/opt/Qtopia/bin/first first.o main.o first.o moc_first.o-L/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/lib -L/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/lib -lqpe -lqtopia -lqte
first.o: In function `non-virtual thunk to first::~first()':
first.cpp:(.text+0x0): multiple definition of `non-virtual thunk to first::~first()'
first.o:first.cpp:(.text+0x0): first defined here
first.o: In function `first::~first()':
first.cpp:(.text+0x10): multiple definition of `first::~first()'
first.o:first.cpp:(.text+0x10): first defined here
first.o: In function `first::~first()':
first.cpp:(.text+0x30): multiple definition of `first::~first()'
first.o:first.cpp:(.text+0x30): first defined here
first.o: In function `non-virtual thunk to first::~first()':
first.cpp:(.text+0x50): multiple definition of `non-virtual thunk to first::~first()'
first.o:first.cpp:(.text+0x50): first defined here
first.o: In function `first::~first()':
first.cpp:(.text+0x60): multiple definition of `first::~first()'
first.o:first.cpp:(.text+0x60): first defined here
first.o: In function `first::user_button()':
first.cpp:(.text+0x90): multiple definition of `first::user_button()'
first.o:first.cpp:(.text+0x90): first defined here
first.o: In function `first::first(QWidget*, char const*, unsigned int)':
first.cpp:(.text+0x110): multiple definition of `first::first(QWidget*, char const*, unsigned int)'
first.o:first.cpp:(.text+0x110): first defined here
first.o: In function `first::first(QWidget*, char const*, unsigned int)':
first.cpp:(.text+0x460): multiple definition of `first::first(QWidget*, char const*, unsigned int)'
first.o:first.cpp:(.text+0x460): first defined here
collect2: ld returned 1 exit status
make: *** Error 1

刘志华 发表于 2012-3-22 21:46:12

原来是Makefile文件中有重复的信息,已经解决了!!

半棵苗 发表于 2012-8-30 17:29:29

本帖最后由 半棵苗 于 2012-8-30 17:29 编辑

谢了,我的也是同样的问题。当时没有仔细查重,漏了几个地方,
以下是我的Makefile

#############################################################################
# Makefile for building first
# Generated by tmake at 16:18, 2012/08/30
#   Project: first
#    Template: app
#############################################################################

####### Compiler, tools and options

CC      =      gcc
CXX      =      g++
CFLAGS      =      -pipe -Wall -W -O2 -DNO_DEBUG
CXXFLAGS=      -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG
INCPATH      =      -I$(QTDIR)/include -I$(QPEDIR)/include
LINK      =      g++
LFLAGS      =      
LIBS      =      $(SUBLIBS) -L$(QPEDIR)/lib -L$(QTDIR)/lib -lqpe -lqtopia -lqte
MOC      =      $(QTDIR)/bin/moc
UIC      =      $(QTDIR)/bin/uic

TAR      =      tar -cf
GZIP      =      gzip -9f

####### Files

HEADERS =      first.h
SOURCES =      first.cpp \
                main.cpp
OBJECTS =      first.o \
                main.o \
#:)                first.o
INTERFACES =      first.ui
UICDECLS =      first.h
UICIMPLS =      first.cpp
SRCMOC      =      moc_first.cpp \
#:)                moc_first.cpp
OBJMOC      =      moc_first.o \
#:)                moc_first.o
DIST      =      
TARGET      =      $(QPEDIR)/image/opt/Qtopia/bin/first
DESKTOP =       $(QPEDIR)/image/opt/Qtopia/apps/EmbedSky/first.desktop
ICON      =       $(QPEDIR)/image/opt/Qtopia/pics/first.png
INTERFACE_DECL_PATH = .

####### Implicit rules

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

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

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

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

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

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

####### Build rules


all: $(TARGET)
      cp -f first.desktop $(DESKTOP)
first.o: moc_first.cpp \


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

moc: $(SRCMOC)

tmake: Makefile

Makefile: first.pro
      tmake first.pro -o Makefile

dist:
      $(TAR) first.tar first.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
      $(GZIP) first.tar

clean:
      -rm -f $(OBJECTS) $(OBJMOC) $(DESKTOP) $(ICON) $(TARGET)
#$(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET)
      -rm -f *~ core

####### Sub-libraries


###### Combined headers


####### Compile

first.o: first.cpp \
                first.h \
                first.ui

main.o: main.cpp \
                first.h \
                /opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/include/qtopia/qpeapplication.h

first.h: first.ui
      $(UIC) first.ui -o $(INTERFACE_DECL_PATH)/first.h

first.cpp: first.ui
      $(UIC) first.ui -i first.h -o first.cpp

###:)###first.o: first.cpp \
                first.h \
                first.ui

moc_first.o: moc_first.cpp \
                first.h

#:)####moc_first.o: moc_first.cpp \
                first.h

moc_first.cpp: first.h
      $(MOC) first.h -o moc_first.cpp

#:) moc_first.cpp: first.h
      $(MOC) first.h -o moc_first.cpp
页: [1]
查看完整版本: 根据手册执行第一个Qt时出现问题