Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to compile on Mac OS X



  • Hi everyone!

    I'm new in Qt, and I got a tutorial where it says that to compile, having a .cpp file, I just need to do this:

    qmake -project
    qmake file.pro
    make

    That works in Windows but in Mac OS X (10.7) it creates a xcode project file by default, and an info.plist file, so, "make" doesn't work.

    I'm new and I don't wanna use QtCreator because it creates a lot of files that I don't need (yet...). So, my question is: Is there an easy way to compile my .cpp files from console on Mac OS X?

    Thanks!

    BTW. I read the qmake tutorial in the QtCreator help and tried with:

    qmake -makefile -o Makefile file.pro

    but still creates the xcode project... :/



  • What do you mean with "It creates a xcode project file by default"?

    Can you please post the output of this commands, you use:

    qmake -project
    qmake file.pro
    make

    Please also post the Makefile after doing qmake file.pro.


  • Lifetime Qt Champion

    Hi and welcome to DevNet,

    Try again passing the macx-g++ mkspec, by default the mkspec is for xcode



  • Hi again! and thank you for your help!

    When I do "qmake -project" there is no output in the console, just it creates the "pro" file (file.pro). Then I do "qmake file.pro", and there is no output again, but two files are created: "info.plist" and "file.xcodeproj". If I try to run "make", the output is:

    make: *** No targets specified and no makefile found. Stop.

    The .xcodeproj file can't be opened with xcode, if I try that xcode says:

    Project file.xcodeproj cannot be opened: didn't find classname for 'isa' key

    So, I can't compile my program.

    SGaist, I can't run macx-g++ (it says "command no found") :/ how can I excecute it?

    Thank you again and sorry for my english, I speak spanish.

    Regards!

    Edit:

    I found this page: https://bugreports.qt-project.org/browse/QTBUG-29371 and did the replacement, and then i got this message:

    Project file.xcodeproj cannot be opened because the project file cannot be parsed.

    :/ Thanks again!



  • okay, maybe one more point for my list "Why I hate MacOS"...

    I know, that you wrote it, but using QtCreator would be solve your problem.
    If you are new in Qt, I prefer to give it a try. You can easily take a look in the reference manual by pressing F1 in the code, so you can find fast your functions for your needs.

    Take also a look to the Shortcuts: http://qt-project.org/wiki/Qt_Creator_Keyboard_Shortcuts
    I also used Eclipse a long time before and I also use it for non-Qt projects. Qt projects are easier to handle (exept for version control).


  • Lifetime Qt Champion

    IIRC you have to install the "command line tools" for XCode then you should be good


Log in to reply