Results 1 to 6 of 6

Thread: Help compiling first Qt Application in Mac OS X using g++

  1. #1

    Default Help compiling first Qt Application in Mac OS X using g++

    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:
    Qt Code:
    1. 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
    To copy to clipboard, switch view to plain text mode 

    And this is what it spits out:
    Qt Code:
    1. /usr/bin/ld: Undefined symbols:
    2. QApplication::exec()
    3. QApplication::QApplication(int&, char**)
    4. QString::fromAscii_helper(char const*, int)
    5. QString::free(QString::Data*)
    6. QWidget::resize(QSize const&)
    7. collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Help compiling first Qt Application in Mac OS X using g++

    You're not linking against Qt libraries. Use qmake - it will generate a proper makefile for you. The tool is explained in Qt docs.

  3. #3

    Default Re: Help compiling first Qt Application in Mac OS X using g++

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Help compiling first Qt Application in Mac OS X using g++

    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.

  5. #5

    Default Re: Help compiling first Qt Application in Mac OS X using g++

    Thanks man. It's working now.

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

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Help compiling first Qt Application in Mac OS X using g++

    Quote Originally Posted by rba1988 View Post
    I want to link it to libpcap or any other dynamic library to add more functionality. What do I do?
    Declaring Other Libraries
    J-P Nurmi

Similar Threads

  1. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 18:37
  2. Replies: 3
    Last Post: 8th December 2006, 18:51
  3. Gnome makes application crash
    By regix in forum Qt Programming
    Replies: 35
    Last Post: 18th August 2006, 19:44
  4. Replies: 10
    Last Post: 28th April 2006, 15:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.