[Qt-interest] Qt newbie needs some help with Xcode

Karol Krizka kkrizka at gmail.com
Fri May 29 15:30:01 CEST 2009


Hi,

I didn't read your full build log yet, but one thing came to mind right
now. In your MainWindow class, do you call the Q_OBJECT macro?

--
Cheers,
Karol Krizka
http://www.krizka.net

On Fri, 2009-05-29 at 15:18 +0200, Norman Rosner wrote:
> mbp:TextEditor jeckyll$ make clean
> rm -f moc_MainWindow.cpp
> rm -f ui_MainWindow.h
> rm -f main.o MainWindow.o moc_MainWindow.o
> rm -f *~ core *.core
> 
> mbp:TextEditor jeckyll$ qmake -spec macx-g++
> 
> mbp:TextEditor jeckyll$ make
> /Developer/Tools/Qt/uic MainWindow.ui -o ui_MainWindow.h
> g++ -c -pipe -g -gdwarf-2 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB - 
> DQT_SHARED -I/usr/local/Qt4.5/mkspecs/macx-g++ -I. -I/Library/ 
> Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore - 
> I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/ 
> QtGui -I/usr/include -I. -I. -I. -F/Library/Frameworks -o main.o  
> main.cpp
> g++ -c -pipe -g -gdwarf-2 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB - 
> DQT_SHARED -I/usr/local/Qt4.5/mkspecs/macx-g++ -I. -I/Library/ 
> Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore - 
> I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/ 
> QtGui -I/usr/include -I. -I. -I. -F/Library/Frameworks -o MainWindow.o  
> MainWindow.cpp
> /Developer/Tools/Qt/moc -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/ 
> local/Qt4.5/mkspecs/macx-g++ -I. -I/Library/Frameworks/ 
> QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/ 
> Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/ 
> usr/include -I. -I. -I. -F/Library/Frameworks -D__APPLE__ -D__GNUC__  
> MainWindow.h -o moc_MainWindow.cpp
> g++ -c -pipe -g -gdwarf-2 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB - 
> DQT_SHARED -I/usr/local/Qt4.5/mkspecs/macx-g++ -I. -I/Library/ 
> Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore - 
> I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/ 
> QtGui -I/usr/include -I. -I. -I. -F/Library/Frameworks -o  
> moc_MainWindow.o moc_MainWindow.cpp
> g++ -headerpad_max_install_names -o TextEditor.app/Contents/MacOS/ 
> TextEditor main.o MainWindow.o moc_MainWindow.o   -F/Library/ 
> Frameworks -L/Library/Frameworks -framework QtGui -framework Carbon - 
> framework AppKit -framework QtCore -lz -lm -framework  
> ApplicationServices
> Undefined symbols:
>    "MainWindow::~MainWindow()", referenced from:
>        vtable for MainWindowin moc_MainWindow.o
>    "MainWindow::~MainWindow()", referenced from:
>        vtable for MainWindowin moc_MainWindow.o
>    "non-virtual thunk to MainWindow::~MainWindow()", referenced from:
>        vtable for MainWindowin moc_MainWindow.o
>    "non-virtual thunk to MainWindow::~MainWindow()", referenced from:
>        vtable for MainWindowin moc_MainWindow.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> make: *** [TextEditor.app/Contents/MacOS/TextEditor] Error 1
> 
> mbp:TextEditor jeckyll$ make clean
> rm -f moc_MainWindow.cpp
> rm -f ui_MainWindow.h
> rm -f main.o MainWindow.o moc_MainWindow.o
> rm -f *~ core *.core
> 
> On 29.05.2009, at 15:15, Karol Krizka wrote:
> 
> > On Fri, 2009-05-29 at 15:03 +0200, Norman Rosner wrote:
> >> After running
> >>
> >> qmake -spec macx-g++ && make the same errors occurred. Also with - 
> >> spec
> >> macx-g++42. So what now? I'm clueless ;(
> >>
> > That's pretty weird, vtable errors almost 100% of the time mean that  
> > you
> > just forgot to regenerate the Makefile by running qmake again. Can you
> > post the entire output of:
> > make clean && make
> >
> > --
> > Cheers,
> > Karol Krizka
> > http://www.krizka.net
> >
> >> cheers,
> >>
> >> norman
> >> On 29.05.2009, at 14:42, Karol Krizka wrote:
> >>
> >>> On Fri, 2009-05-29 at 14:36 +0200, Norman Rosner wrote:
> >>>> Thanks for the quick answer. This is my project file:
> >>>>
> >>>> ######################################################################
> >>>> # Automatically generated by qmake (2.01a) Di Mai 26 17:42:20 2009
> >>>> ######################################################################
> >>>>
> >>>> TEMPLATE = app
> >>>> TARGET =
> >>>> DEPENDPATH += .
> >>>> INCLUDEPATH += /Users/jeckyll/studium/cpp/cpp2/TextEditor/. .
> >>>>
> >>>> # Input
> >>>> HEADERS += MainWindow.h
> >>>> FORMS += MainWindow.ui
> >>>> SOURCES += main.cpp MainWindow.cpp
> >>>>
> >>> Try compiling from Terminal. See if you get the same errors or if it
> >>> is
> >>> something XCode specific.
> >>>
> >>> qmake -spec-gcc && make
> >>>
> >>>> It seems to me that all headers and sources are where they should  
> >>>> be
> >>>> right?
> >>>> But it's not compiling. I get the same errors.
> >>>>
> >>>> On 29.05.2009, at 14:11, Karol Krizka wrote:
> >>>>
> >>>>> On Fri, 2009-05-29 at 14:00 +0200, Norman Rosner wrote:
> >>>>>> Hi folks,
> >>>>>>
> >>>>>> I'm stuck in a problem and I can't find a solution to it. I'm  
> >>>>>> using
> >>>>>> the current version of Qt with Xcode. Here is what I did:
> >>>>>> In my Project Folder there's a main.cpp and i have set up a
> >>>>>> MainWindow.ui file.
> >>>>>>
> >>>>>> I set up a project using qmake -project in a folder.
> >>>>>> Then I ran qmake -spec mac-xcode
> >>>>>>
> >>>>>> Now when I start up the created Xcode project I created a new  
> >>>>>> Class
> >>>>>> that inherits from Ui::MainWindow and QMainWindow in MainWindow.h
> >>>>>> and
> >>>>>> MainWindow.cpp.
> >>>>>>
> >>>>>> So now, when I run Build and Go I get errors like this one:
> >>>>>>
> >>>>>> "MainWindow::~MainWindow()", referenced from:
> >>>>>> vtable for MainWindowin moc_MainWindow.o
> >>>>>>
> >>>>>> I think it has something to do with moc and compiling  
> >>>>>> MainWindow.ui
> >>>>>>
> >>>>>> So what am I doing wrong?
> >>>>>>
> >>>>>> Do i always have to run qmake -spec macx-xcode when I added new
> >>>>>> files?
> >>>>>>
> >>>>> I'm pretty sure you have to run that everytime you add new files.
> >>>>> The
> >>>>> command only generates the initial XCode Project, but it does not
> >>>>> updated it after you add new classes. Also make sure that  
> >>>>> your .pro
> >>>>> file
> >>>>> has the headers for the new class.
> >>>>>
> >>>>> HEADERS +=  MainWindow.h
> >>>>> SOURCES += main.cpp MainWindow.cpp
> >>>>>
> >>>>>> I looked into two books about Qt but i didn't find the answer.
> >>>>>>
> >>>>>> Would be nice to get some help from somebody who works with Xcode
> >>>>>> and
> >>>>>> Qt too.
> >>>>>
> >>>
> >>> --
> >>> Cheers,
> >>> Karol Krizka
> >>> http://www.krizka.net
> >>>
> >>
> >> _______________________________________________
> >> Qt-interest mailing list
> >> Qt-interest at trolltech.com
> >> http://lists.trolltech.com/mailman/listinfo/qt-interest
> >
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list