How to compile a simple Qt and c++ application using g++ on mac os x?


I am trying to use Qt for a project in school but am running into problems. I started following the tutorials and I am running into Makefile problems. Most of the tutorials say to run qmake -project, then qmake and finally make. But when I try this I run into the error make: *** No targets specified and no makefile found. Stop. I dont know much about Makefiles really. Could someone help point me in the right direction?

1/13/2009 10:36:20 PM

Accepted Answer

qmake on OS X creates Xcode project files. You can create a Makefile with:

qmake -spec macx-g++

If you don't want the Makefile to create an app bundle, you could also remove 'app_bundle' your configuration, for example by adding the following lines to your project file.

mac {
  CONFIG -= app_bundle
1/14/2009 8:56:48 PM

As other posters have pointed out, the default behavior of qmake on the Mac is to create xCode project files. You can type in something special every time you run qmake or add a few lines to each project file. There is a more permanent solution. I run into this every time I install Qt on my Mac. From a command line type in the following:

cd /usr/local/Qt4.5/mkspecs/

sudo rm default

sudo ln -sf macx-g++ default

The directory specified in the first online command may need some tweaking. The first "sudo" will require an administrative password.

What this does is remove the offending file that specifies that the default -spec switch is mac-xcode or something like that. We then replace it with a file specifying we use the macx-g++ switch by default.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow