PDA

View Full Version : Qt 4.6.x on MacOS X Snow Leo - compiling with g++ in Terminal window?



cargath
16th May 2010, 16:54
Shouldn't this work?

I tried both installing QtCreator SDK and Qt4-mac from Macports. In the QtCreator preferences it says Qt was found in my PATH variable. I also export the path to my Qt-libs in my .profile file (export PATH=/lib:/bin:/sbin:/usr/lib:/usr/bin:/usr/sbin:/usr/local/lib:/usr/local/bin:/usr/local/Qt4.6:$PATH).

Compiling with QtCreator works (with XCode too). But i really like to write small projects just with TextMate and compile them with my gcc in a terminal window. When i try to import <QtGui> oder "QtGui.h" i always get "no such file or directory"-errors.

What do i do wrong?

(i guess this totally newbie question was asked a hundred times, but i couldn't find an answer)

Lykurg
16th May 2010, 17:58
How do you create your Makefile?
/usr/bin/qmake -spec /usr/local/Qt4.6/mkspecs/macx-g++ -macx CONFIG+=release -o Makefile foo.pro works fine for me.

cargath
16th May 2010, 22:55
Well, since i don't use QtCreator i don't have a .pro file. I do it the old fashioned way - by hand.
Didn't knew i had to import some headers and frameworks via -I / -F / -L into my compiler. It's the first time i use an external framework within my code. The Qt-FAQ stated it would be enough to have it in my $PATH to use it ;)

I've still one little question, and since i already opened this thread...
What exactly does "Q_OBJECT" do in the beginning of a class-definition? I always see this in examples from the qt-homepage. If write this in the beginning if my GLCanvas class which is derived from QGLWidget i get:

Undefined symbols:
"vtable for GLCanvas", referenced from:
__ZTV8GLCanvas$non_lazy_ptr in ccTZCYSb.o
(maybe you meant: __ZTV8GLCanvas$non_lazy_ptr)