Qt and Eclipse under Mac OS X

There is a plugin for Eclipse which makes it possible to develop Qt applications with Eclipse. However, there are only versions for Linux and Windows at the moment. If you are working with Mac OS X you cannot use the plugin. I will show, how you are be able to develop Qt applications with Ecplise and Mac OS X.

  1. Install XCode and Apple Developer Tools.
  2. Install Qt.
  3. Eclipse installieren.
  4. Launch Eclipse.
  5. Install Eclipse CDT (C Development Tools), if they are not installed, yet:
    1. Call "Help / Software Updates…".
    2. Chose "Add Site…" at the "Available Software" tab and add http://download.eclipse.org/releases/ganymede.
    3. You may need to click "Refresh". Then expand the list below the newly added domain and check "Eclipse C/C++ Development Platform" as well as "Eclipse C/C++ Development Tools".
    4. Click "Install…".
  6. Call "Run / External Tools / External Tools Configurations…".
  7. Double click at "Program" to add a new program.
  8. Enter "qmake Makefile Generation" as name.
  9. Enter the path to qmake in the "Location" field. This will be "/usr/bin/qmake" in standard installations. Enter "${project_loc}" in the "Working Directory" field and "-spec macx-g++" in the arguments field.
  10. Check "Refresh resources upon completion", "The entire workspace" und "Recursivly include sub-folders" in the "Refresh" tab.
  11. Uncheck "Build before launch" in the "Build" tab.
  12. You can also uncheck "Allocate Console" in the "Common" tab, but you do not have to.
  13. Quit Eclipse.
  14. Download my QtHeaders plugin.
  15. Install the QtHeaders plugin. To do so copy the .jar file in the plugins directory in your Eclipse directory.

Now you have configured Eclipse for the Qt application development. But you have to set some things in the project settings of each Qt project. To create a new Qt project follow these steps:

  1. Call "File / New / C++ Project".
  2. Enter the name and directory.
  3. Chose "Makefile project / Empty Project" as "Project type".
  4. Chose "MacOSX GCC" as "Toolchain" and click "Next".
  5. Mark "MacOSX GCC" and click "Advanced settings…".
  6. Click "Import…" in the section "Builders", chose "qmake Makefile Generation" and click "OK". Then move "qmake Makefile Generation [Builder]" to the top in the list.
  7. Chose the "Mach-O Parser" as "Binary Parser" under "C/C++ Build / Settings".
  8. Add the needed include directories for "GNU C++" in the tab "Includes" under "C/C++ General / Paths and Symbols". In a standard Qt installation these are the directories which match the pattern "/Library/Frameworks/Qt<modulename>.framework/Headers". For example: "/Library/Frameworks/QtCore.framework/Headers" or "/Library/Frameworks/QtGui.framework/Headers". Sometimes Eclipse seems to find out these directories itself, if they are needed. However, I was not able to figure out under which conditions and in which way, yet (maybe Eclipse uses the Makefile for that?)
  9. You may want to set the directories under "Source Location" and "Output Location" as needed.
  10. Close the project settings by clicking on "OK" exit the project assistent with "Finish".

The only thing missing now is a qmake project file. I often write this file myself, but qmake also provides the option "-project" to generate such a project file. You may want to add a corrsesponding program call unter "Run / External Tools" and maybe even want to add it to the beginning of the list of "Builders" in the project settings to have "qmake -project" executed every time you compile the project.