• 5788阅读
  • 3回复

qt 4.4 make时候提示undefined reference to .... [复制链接]

上一主题 下一主题
离线marixwong
 

只看楼主 倒序阅读 楼主  发表于: 2008-10-03
— 本帖被 XChinux 执行加亮操作(2008-10-04) —
我在qt 4.4下面作了个小程序,具体是在一个窗口中弹出另一个窗口。。
我写了两个类,一个是directoryviewer,一个是newWindow..然后在directoryviewer中
用newWindow newWindow(text);text是需要传入的文本参数。。
然后显示窗口newWindow..show();
可是make的时候提示undefined reference to 'newWindow:newWindow[in-charge](QString, QWidget*,char const *)'
collect2:ld returned 1 exit status..
我就是用newWindow newWindow(text)调用构造函数。。。可是怎么会在make的最后提示出错呢。。。
下面是我的makefile。。。
#############################################################################
# Makefile for building: directoryviewer
# Generated by qmake (2.01a) (Qt 4.4.2) on: ?? ?? 3 16:11:16 2008
# Project:  directoryviewer.pro
# Template: app
# Command: /usr/local/Trolltech/Qt-4.4.2/bin/qmake -unix -o Makefile directoryviewer.pro
#############################################################################

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

CC            = gcc
CXX          = g++
DEFINES      = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS        = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS      = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
INCPATH      = -I../../local/Trolltech/Qt-4.4.2/mkspecs/linux-g++ -I. -I../../local/Trolltech/Qt-4.4.2/include/QtCore -I../../local/Trolltech/Qt-4.4.2/include/QtCore -I../../local/Trolltech/Qt-4.4.2/include/QtGui -I../../local/Trolltech/Qt-4.4.2/include/QtGui -I../../local/Trolltech/Qt-4.4.2/include -I. -I.
LINK          = g++
LFLAGS        = -Wl,-rpath,/usr/local/Trolltech/Qt-4.4.2/lib
LIBS          = $(SUBLIBS)  -L/usr/local/Trolltech/Qt-4.4.2/lib -lQtGui -L/usr/local/Trolltech/Qt-4.4.2/lib -L/usr/X11R6/lib -pthread -lpng -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lglib-2.0 -lrt -ldl -lpthread
AR            = ar cqs
RANLIB        =
QMAKE        = /usr/local/Trolltech/Qt-4.4.2/bin/qmake
TAR          = tar -cf
COMPRESS      = gzip -9f
COPY          = cp -f
SED          = sed
COPY_FILE    = $(COPY)
COPY_DIR      = $(COPY) -r
INSTALL_FILE  = install -m 644 -p
INSTALL_DIR  = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
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

SOURCES      = directoryviewer.cpp \
        main.cpp moc_directoryviewer.cpp moc_newWindow.cpp
OBJECTS      = directoryviewer.o \
        main.o \
        moc_directoryviewer.o moc_newWindow.o
DIST          = ../../local/Trolltech/Qt-4.4.2/mkspecs/common/g++.conf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/common/unix.conf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/common/linux.conf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/qconfig.pri \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/qt_functions.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/qt_config.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/exclusive_builds.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/default_pre.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/release.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/default_post.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/warn_on.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/qt.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/unix/thread.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/moc.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/resources.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/uic.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/yacc.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/lex.prf \
        directoryviewer.pro
QMAKE_TARGET  = directoryviewer
DESTDIR      =
TARGET        = directoryviewer

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

.SUFFIXES: .o .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):  $(OBJECTS) 
    $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

Makefile: directoryviewer.pro  ../../local/Trolltech/Qt-4.4.2/mkspecs/linux-g++/qmake.conf ../../local/Trolltech/Qt-4.4.2/mkspecs/common/g++.conf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/common/unix.conf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/common/linux.conf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/qconfig.pri \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/qt_functions.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/qt_config.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/exclusive_builds.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/default_pre.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/release.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/default_post.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/warn_on.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/qt.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/unix/thread.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/moc.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/resources.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/uic.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/yacc.prf \
        ../../local/Trolltech/Qt-4.4.2/mkspecs/features/lex.prf \
        /usr/local/Trolltech/Qt-4.4.2/lib/libQtGui.prl \
        /usr/local/Trolltech/Qt-4.4.2/lib/libQtCore.prl
    $(QMAKE) -unix -o Makefile directoryviewer.pro
../../local/Trolltech/Qt-4.4.2/mkspecs/common/g++.conf:
../../local/Trolltech/Qt-4.4.2/mkspecs/common/unix.conf:
../../local/Trolltech/Qt-4.4.2/mkspecs/common/linux.conf:
../../local/Trolltech/Qt-4.4.2/mkspecs/qconfig.pri:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/qt_functions.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/qt_config.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/exclusive_builds.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/default_pre.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/release.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/default_post.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/warn_on.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/qt.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/unix/thread.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/moc.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/resources.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/uic.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/yacc.prf:
../../local/Trolltech/Qt-4.4.2/mkspecs/features/lex.prf:
/usr/local/Trolltech/Qt-4.4.2/lib/libQtGui.prl:
/usr/local/Trolltech/Qt-4.4.2/lib/libQtCore.prl:
qmake:  FORCE
    @$(QMAKE) -unix -o Makefile directoryviewer.pro

dist:
    @$(CHK_DIR_EXISTS) .tmp/directoryviewer1.0.0 || $(MKDIR) .tmp/directoryviewer1.0.0
    $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/directoryviewer1.0.0/ && $(COPY_FILE) --parents directoryviewer.h .tmp/directoryviewer1.0.0/ && $(COPY_FILE) --parents directoryviewer.cpp main.cpp .tmp/directoryviewer1.0.0/ && (cd `dirname .tmp/directoryviewer1.0.0` && $(TAR) directoryviewer1.0.0.tar directoryviewer1.0.0 && $(COMPRESS) directoryviewer1.0.0.tar) && $(MOVE) `dirname .tmp/directoryviewer1.0.0`/directoryviewer1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/directoryviewer1.0.0


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


####### Sub-libraries

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


mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

compiler_moc_header_make_all: moc_directoryviewer.cpp moc_newWindow.cpp
compiler_moc_header_clean:
    -$(DEL_FILE) moc_directoryviewer.cpp moc_newWindow.cpp
moc_directoryviewer.cpp: newWindow.h \
        directoryviewer.h
    /usr/local/Trolltech/Qt-4.4.2/bin/moc $(DEFINES) $(INCPATH) directoryviewer.h -o moc_directoryviewer.cpp

moc_newWindow.cpp: newWindow.h
    /usr/local/Trolltech/Qt-4.4.2/bin/moc $(DEFINES) $(INCPATH) newWindow.h -o moc_newWindow.cpp

compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
    -$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean: compiler_moc_header_clean

####### Compile

directoryviewer.o: directoryviewer.cpp newWindow.cpp directoryviewer.h \
        newWindow.h
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o directoryviewer.o directoryviewer.cpp

main.o: main.cpp directoryviewer.h \
        newWindow.h
    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp

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

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

####### Install

install:  FORCE

uninstall:  FORCE

FORCE:

离线marixwong

只看该作者 1楼 发表于: 2008-10-03
自己先顶一下。。。麻烦那位兄弟姐妹帮个忙。。小弟不胜感激。。
离线nmiirq

只看该作者 2楼 发表于: 2008-10-03
貌似构造函数与调用时的函数没有对上!
把二者帖出来CODE看一下
离线XChinux

只看该作者 3楼 发表于: 2008-10-04
你有的函数没有实现。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个