Skip to main content

Setting up a C++/QT project on eclipse under Mac OS X

The compile steps with Qt4 are:
  1. qmake -project [generates a .pro file based on the files you have in the root directory]
  2. qmake [genrates the Makefile from the .pro file]
  3. make [gnu make that uses the Makefile to generate your project as a *.app folder]
To get eclipse to follow this chain I did
  1. Fire up eclipse and choose File->New->C++ Project
  2. Uncheck 'use default location' and browse to the root of your code tree
  3. Enter a Project name e.g. ChhobiQT
  4. Pick Empty Project (leave MavOSX GCC as is)
    At this stage eclipse will find your files/subdirectories and try and compile and probably give you an error. Ignore this smart ass behavior or uncheck Project->Build automatically
  5. Project->Properties (If this is grayed out, make sure to click and highlight ChhobiQT)
  6. ->C/C++ Build : Uncheck 'Generate Makefiles automatically'
  7. 'Build directory' set it to the variable ${project_loc}
  8. Run->External Tools Dialog
  9. Under program create a new entry and set:
    Name : qmake1
    Location : location of qmake on your system e.g. /usr/local/Trolltech/Qt-4.4.0/bin/qmake
    Working directory : ${project_loc}
    Arguments : -project
    This 'External program' will enable you to generate a *.pro file when you need it
  10. Make an identical entry but name is qmake2 and make Arguments blank
    This entry will let you generate a Makefile when you add files to the project
  11. Now click Run->External Tools->qmake1 and then qmake2
  12. Hit F5 to refresh the Project explorer
    You should see a .pro file and a Makefile
  13. Project->Build Project
    You should now have a *.app file
  14. Run->Run
    Your application should now run
Each time you add a new file to the configuration you need to rerun qmake -project and qmake.

Note on Code Completion:
Go to Project->Properties->C/C++ General->Paths and Symbols
In the GNU C++ tab add the following paths (depending on the version of QT)
/usr/local/Trolltech/Qt-4.4.1/include/QtSql (if you use sql)

The rebuild code index
This will take care of code competion and things like Q_OBJECT being not recognized


  1. I'm just tinkering with Qt for the Mac. I'm having some trouble... qmake does not generate a makefile; instead it generates a .xcodeproj file. Any clues on how I can get it to use Makefiles under MacOS X?

  2. try
    qmake -spec macx-g++ -macx

    you saved me a lot of pain

  4. Hi.

    I have followed your steps and I get a working .app file and the app works fine. BUT I don't get code completion in Eclipse. I have no error highlights but some q_object highlights.

    Any Ideas?

    Using cdt 5.0.2.


  5. Hi,

    I'm assuming you did the last step at the end. You will have to tailor the paths to your local install of QT. And (**this is important**) QT should be compiled with symbols on. For some reason the actual install of QT I use 4.4.4 does not work, I link to an older version 4.4.1 I forget exactly what it is, but I think you have to **configure as debug** which generates symbol tables. I don't know enough about the internals to explain the mechanism.


  6. thanks, it works!

  7. HI,

    First of all thanks for creating this helpful document.

    I have follow your steps but when qmake1 command to create .pro file i found the below error.

    ERROR :
    make: *** No rule to make target `all'. Stop.

    While someone please guid me to solve this issue.

  8. This is the first tutorial that actually works. Under Linux too. Thanks!


Post a Comment

Popular posts from this blog

Flowing text in inkscape (Poster making)

You can flow text into arbitrary shapes in inkscape. (From a hint here).

You simply create a text box, type your text into it, create a frame with some drawing tool, select both the text box and the frame (click and shift) and then go to text->flow into frame.


The omnipresent anonymous asked:
Trying to enter sentence so that text forms the number three...any ideas?
The solution:
Type '3' using the text toolConvert to path using object->pathSize as necessaryRemove fillUngroupType in actual text in new text boxSelect the text and the '3' pathFlow the text

Python: Multiprocessing: passing multiple arguments to a function

Write a wrapper function to unpack the arguments before calling the real function. Lambda won't work, for some strange un-Pythonic reason.

import multiprocessing as mp def myfun(a,b): print a + b def mf_wrap(args): return myfun(*args) p = mp.Pool(4) fl = [(a,b) for a in range(3) for b in range(2)] #mf_wrap = lambda args: myfun(*args) -> this sucker, though more pythonic and compact, won't work, fl)

Pandas panel = collection of tables/data frames aligned by index and column

Pandas panel provides a nice way to collect related data frames together while maintaining correspondence between the index and column values:

import pandas as pd, pylab #Full dimensions of a slice of our panel index = ['1','2','3','4'] #major_index columns = ['a','b','c'] #minor_index df = pd.DataFrame(pylab.randn(4,3),columns=columns,index=index) #A full slice of the panel df2 = pd.DataFrame(pylab.randn(3,2),columns=['a','c'],index=['1','3','4']) #A partial slice df3 = pd.DataFrame(pylab.randn(2,2),columns=['a','b'],index=['2','4']) #Another partial slice df4 = pd.DataFrame(pylab.randn(2,2),columns=['d','e'],index=['5','6']) #Partial slice with a new column and index pn = pd.Panel({'A': df}) pn['B'] = df2 pn['C'] = df3 pn['D'] = df4 for key in pn.items: print pn[key] -> output …