PDA

View Full Version : Help compiling first Qt Application in Mac OS X using g++



rba1988
25th June 2007, 17:04
Hi! I recently installed Qt 4 on my Powerbook G4 and everything works out great. The only problem is I don't know how to compile programs! I've tried the simple hello world program in the tutorial and couldn't get how the qmake works. Everytime I create a .pro file, I don't know where to go next. I've done everything the tutorial told me to do but whenever I type in make, it says it doesn't have any target files or something...

Anyway...I never did plan to use qmake. I would really like to compile using g++. I've acquired a document that teaches how to compile using g++ but it won't work for me because of the last line what requires me to input "-lqt". It's a link to a dylib named qt which isn't in my machine for some reason. I wonder why...

So here's what I've got so far:


g++ -g -o test test.cpp -I/usr/local/Trolltech/Qt-4.1.3/include/QtGui -I/usr/local/Trolltech/Qt-4.1.3/include/QtCore -L/usr/local/Trolltech/Qt-4.1.3/lib


And this is what it spits out:


/usr/bin/ld: Undefined symbols:
QPushButton::QPushButton(QString const&, QWidget*)
QPushButton::~QPushButton()
QApplication::exec()
QApplication::QApplication(int&, char**)
QApplication::~QApplication()
QString::fromAscii_helper(char const*, int)
QString::free(QString::Data*)
QWidget::resize(QSize const&)
collect2: ld returned 1 exit status


What am I doing wrong? I really want to start coding. But if I can't get past that hello world, how am I supposed to start? I'm trying my best to not be tempted by developing Java applications since I think C++ is more versatile and...it's C! You can make anything. No limits. hehe.

Any help would be appreciated.

I haven't started coding in Qt yet and I already think it's a nice API to work on.

Specs: Mac OS X 10.4.10, Powerbook G4, PPC 1.5 Ghz

Thanks in advance

wysota
26th June 2007, 01:33
You're not linking against Qt libraries. Use qmake - it will generate a proper makefile for you. The tool is explained in Qt docs.

rba1988
26th June 2007, 04:37
But I want to use g++ since qmake doesn't seem to work with me. qmake generates the Makefile named Makefile.xcodeproj or something. Then when I type in make, it says that there aren't makefiles inside the directory. Also, I feel that I have more control when using g++. Any ideas on this? Mac OSX runs on UNIX so I guess Qt is installed in similar/common directories as with UNIX.

wysota
26th June 2007, 09:17
qmake will generate g++ makefiles as well. You probably have the environment set up incorrectly. For the time being you can force qmake to generate a makefile for g++ by passing a "-spec macx-g++" option to qmake, but in the long run you should make sure your QMAKESPEC points to macx-g++ or that qmake doesn't locate XCode.

rba1988
26th June 2007, 13:04
Thanks man. It's working now.:D

One more thing: I want to link it to libpcap or any other dynamic library to add more functionality. What do I do?

jpn
26th June 2007, 13:10
I want to link it to libpcap or any other dynamic library to add more functionality. What do I do?
Declaring Other Libraries (http://doc.trolltech.com/4.3/qmake-project-files.html#declaring-other-libraries)