Results 1 to 3 of 3

Thread: Using qmake with an Objective C project

  1. #1
    Join Date
    Feb 2012
    Posts
    11
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Using qmake with an Objective C project

    Hey everyone,

    I'm trying to learn a bit of Objective C, and figured that I could just use a regular qmake project and Qt Creator as an IDE. I didn't find much documentation regarding this, so I just fooled around a bit, trying to see if I could make it work. Well, I can't Here's my current .pro file:
    Qt Code:
    1. LIBS += -lobjc
    2.  
    3. OBJECTIVE_HEADERS += Hello.h
    4.  
    5. OBJECTIVE_SOURCES += Hello.m \
    6. main.m
    To copy to clipboard, switch view to plain text mode 
    When I try to compile it, I get the following output:
    Qt Code:
    1. g++ -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -Wl,-O1 -o objc -L/usr/lib -lobjc -lQtGui -lQtCore -lpthread
    2. /usr/lib/gcc/i686-pc-linux-gnu/4.6.2/../../../crt1.o: In function `_start':
    3. (.text+0x18): undefined reference to `main'
    4. collect2: ld returned 1 exit status
    5. make: *** [objc] Error 1
    To copy to clipboard, switch view to plain text mode 
    If I compile it manually, with "gcc -lobjc Hello.m main.m -o Hello" everything goes smoothly, so it's clearly a problem of my understanding of qmake

    Cheers

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Using qmake with an Objective C project

    Try adding:
    Qt Code:
    1. CONFIG += objective_c
    To copy to clipboard, switch view to plain text mode 
    if you are on a Mac. This should pull in the Objective C custom compiler that is going to do something with the OBJECTIVE_SOURCES variable (not OBJECTIVE_HEADERS AFAICT). If you are not on Mac then the feature does not exist, and you will probably have to roll your own.

    I've also seen mention that the file extension needs to .mm but I have not verified that.
    Last edited by ChrisW67; 4th March 2012 at 22:35. Reason: updated contents

  3. #3
    Join Date
    Feb 2012
    Posts
    11
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using qmake with an Objective C project

    I am not on a Mac (but I'm planning on getting the next-gen iMac), I'm running Arch Linux right now. I will try using the .mm extension, and see if it fixes anything.

    Cheers

Similar Threads

  1. Qt 4.6.2 qmake -project problem
    By vespasianvs in forum Installation and Deployment
    Replies: 0
    Last Post: 25th February 2010, 02:31
  2. Replies: 1
    Last Post: 3rd December 2009, 23:34
  3. QMake Project Files....
    By TemporalBeing in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2009, 16:15
  4. qmake behaviour through project's .pro
    By vladeck in forum Newbie
    Replies: 5
    Last Post: 28th February 2008, 20:53
  5. QT and Objective-C
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 26th June 2006, 19:33

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
  •  
Qt is a trademark of The Qt Company.