2 Attachment(s)
Can't compile sample - Mac OS X 10.5, latest QT SDK download
Hi. This is my second shot at Qt. I tried a year ago and gave up. Similar errors as now. Hopefully, I can get it working this time.
I've just downloaded the latest SDK. I'm running current Leopard. Xcode 3.1 is installed and I use it for Java, C and C++ development all the time.
For the life of me, I cannot compile the sample on page 4 of the Qtbook (C++ GUI Programming with Qt4, 2nd Edition). ("Hello QT!)
I've entered the program into a qt_test2.cpp file in a qt_test2 folder. (~/Xcode/qt_test2/qt_test2.cpp).
I run qmake while in that folder:
and it creates qt_test2.pro. Now, I have 2 files in /qt_test2.
Then, I run:
Code:
qmake -spec macx-xcode qt_test2.pro
and the folder now contains:
Code:
rw-r--r-- 1 toddburch toddburch 600 Sep 28 21:33 Info.plist
-rw-r--r-- 1 toddburch toddburch 293 May 1 2008 qt_test2.cpp
-rw-r--r-- 1 toddburch toddburch 594 Sep 28 21:32 qt_test2.pro
drwxr-xr-x 5 toddburch toddburch 170 Sep 28 21:33 qt_test2.xcodeproj
and the xcodeproj contains:
Code:
~/Xcode/qt_test2/qt_test2.xcodeproj toddburch $ ls -l
total 40
-rw-r--r-- 1 toddburch toddburch 11269 Sep 28 21:33 project.pbxproj
-rw-r--r-- 1 toddburch toddburch 3488 Sep 28 21:33 qt_makeqmake.mak
-rw-r--r-- 1 toddburch toddburch 2549 Sep 28 21:33 qt_preprocess.mak
Now, I've run qmake in "project mode" and then in "make mode". There's no .app,
which I expect, as I want to compile using Xcode. In Xcode, I open the qt_test2.xcodeproj file. (Project Screenshot attached).
I then click Build in Xcode and get lots of error in code that is not mine. Here's a summary in the other screenshot.
What am I doing wrong? Thanks, Todd.
Re: Can't compile sample - Mac OS X 10.5, latest QT SDK download
So, I don't want to use Makefiles, but I figured I would try it while waiting for an answer. Here's the result. No bueno. (Note I created a new folder and source file)
Just before this Make attempt, I entered: qmake qt1.pro
Code:
~/Xcode/qt1 toddburch $ qmake -spec macx-g++ qt1.pro
~/Xcode/qt1 toddburch $ ls -l
total 40
-rw-r--r-- 1 toddburch toddburch 10328 Sep 28 22:58 Makefile
-rw-r--r-- 1 toddburch toddburch 293 Sep 28 22:47 qt1.cpp
-rw-r--r-- 1 toddburch toddburch 589 Sep 28 22:55 qt1.pro
~/Xcode/qt1 toddburch $ make
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. -F/Library/Frameworks -o qt1.o qt1.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. -F/Library/Frameworks -D__APPLE__ -D__GNUC__ /Library/Frameworks/QtGui.framework/Versions/4/Headers/qapplication.h -o moc_qapplication.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. -F/Library/Frameworks -o moc_qapplication.o moc_qapplication.cpp
moc_qapplication.
cpp: In member function ‘
virtual int QApplication::qt_metacall(QMetaObject::Call,
int,
void**)’
:moc_qapplication.cpp:110: error: invalid use of undefined type ‘struct QApplicationPrivate’
/Library/Frameworks/QtCore.framework/Headers/qobject.h:295: error: forward declaration of ‘struct QApplicationPrivate’
moc_qapplication.
cpp:120: error
: invalid use of undefined type ‘
struct QIcon’
/Library
/Frameworks
/QtGui.
framework/Versions
/4/Headers
/qapplication.
h:72: error
: forward declaration of ‘
struct QIcon’
make: *** [moc_qapplication.o] Error 1
~/Xcode/qt1 toddburch $
Here's my source.
Code:
#include </Library/Frameworks/QtGui.framework/headers/QApplication>
#include </Library/Frameworks/QtGui.framework/headers/QLabel>
int main (int argc, char * argv[]) {
label->show() ;
return app.exec() ;
}
User error? Install error? Qt error?
For as world class as Qt is made out to be, I'm not impressed yet.
1 Attachment(s)
Re: Can't compile sample - Mac OS X 10.5, latest QT SDK download
If the graphic is difficult to read, attached is a copy and paste of the build errors from Xcode.
The errors apears to be in the moc_qapplication, not my code.
Re: Can't compile sample - Mac OS X 10.5, latest QT SDK download
Could this be an issue related to installing 4.5 on top of 4.3.3?
I did not delete the previous version - I made an assumption that the install would be smart enough to do the right thing.
Re: Can't compile sample - Mac OS X 10.5, latest QT SDK download
Congratulations on one of the longest monologues I've seen in a forum ;)
Looks like it is not finding the headers. I'm not an OS X user, but I would assume that you do not need to spell out the full path to the headers; qmake and gcc take care of the path to find them. The stereotypical "Hello, World" looks like:
Code:
#include <QApplication>
#include <QLabel>
int main (int argc, char * argv[]) {
label->show() ;
return app.exec() ;
}
Try that for starters.
will tell what version of Qt it thinks it is using. The Makefile should be using the same version.
Re: Can't compile sample - Mac OS X 10.5, latest QT SDK download
Thanks Chris.
When not specifying the full path and just
coding as you've shown, I get the same
exact errors.
I can check the version again to confirm
when I get back in town. Thanks
Re: Can't compile sample - Mac OS X 10.5, latest QT SDK download
I uninstalled Qt and reinstalled. Same errors.
Code:
~/Xcode/qt_test2 toddburch $ qmake -v
QMake version 2.01a
Using Qt version 4.5.2 in /Library/Frameworks
What next? Please help. Thanks, Todd