|
我的Makefile文件是这样的
####### 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 = first
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)
$(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) $(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
moc_first.o: moc_first.cpp \
first.h
moc_first.cpp: first.h
$(MOC) first.h -o moc_first.cpp
然后编译时出现下列错误
[root@EmbedSky first]# make
g++ -o first first.o main.o first.o moc_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 `first::user_button()':
first.cpp:(.text+0x0): multiple definition of `first::user_button()'
first.o:first.cpp:(.text+0x0): first defined here
first.o: In function `non-virtual thunk to first::~first()':
first.cpp:(.text+0x10): multiple definition of `non-virtual thunk to first::~first()'
first.o:first.cpp:(.text+0x10): first defined here
first.o: In function `first::~first()':
first.cpp:(.text+0x20): multiple definition of `first::~first()'
first.o:first.cpp:(.text+0x20): first defined here
first.o: In function `first::~first()':
first.cpp:(.text+0x40): multiple definition of `first::~first()'
first.o:first.cpp:(.text+0x40): first defined here
first.o: In function `non-virtual thunk to first::~first()':
first.cpp:(.text+0x60): multiple definition of `non-virtual thunk to first::~first()'
first.o:first.cpp:(.text+0x60): first defined here
first.o: In function `first::~first()':
first.cpp:(.text+0x70): multiple definition of `first::~first()'
first.o:first.cpp:(.text+0x70): first defined here
first.o: In function `first::first(QWidget*, char const*, unsigned int)':
first.cpp:(.text+0xa0): multiple definition of `first::first(QWidget*, char const*, unsigned int)'
first.o:first.cpp:(.text+0xa0): first defined here
first.o: In function `first::first(QWidget*, char const*, unsigned int)':
first.cpp:(.text+0x330): multiple definition of `first::first(QWidget*, char const*, unsigned int)'
first.o:first.cpp:(.text+0x330): first defined here
moc_first.o: In function `first::className() const':
moc_first.cpp:(.text+0x0): multiple definition of `first::className() const'
moc_first.o:moc_first.cpp:(.text+0x0): first defined here
moc_first.o: In function `first::staticMetaObject()':
moc_first.cpp:(.text+0x40): multiple definition of `first::staticMetaObject()'
moc_first.o:moc_first.cpp:(.text+0x40): first defined here
moc_first.o:(.bss+0x0): multiple definition of `first::metaObj'
moc_first.o:(.bss+0x0): first defined here
moc_first.o: In function `first::tr(char const*, char const*)':
moc_first.cpp:(.text+0x100): multiple definition of `first::tr(char const*, char const*)'
moc_first.o:moc_first.cpp:(.text+0x100): first defined here
moc_first.o: In function `first::tr(char const*)':
moc_first.cpp:(.text+0x140): multiple definition of `first::tr(char const*)'
moc_first.o:moc_first.cpp:(.text+0x140): first defined here
moc_first.o: In function `first::initMetaObject()':
moc_first.cpp:(.text+0x180): multiple definition of `first::initMetaObject()'
moc_first.o:moc_first.cpp:(.text+0x180): first defined here
collect2: ld 返回 1
make: *** [first] 错误 1 |
|