wxwidgets and C++ in an xCode project (OS X 10.6.6)
This article describes the creation of an xCode project to use wxwidgets and C++. It assumes you have Mac OS X 10.6.6 and xCode 3.2.5 (thats what I had).

First, install wxwidgets using MacPorts. (This article doesn't explain MacPorts but assumes it is already installed on your Mac)
sudo port install wxWidgets

Follow the instructions from wiki.wxwidgets.org:
- Start Xcode.
- Choose menu item File --> New Project --> Empty Project (under other)
- Name the project and place it wherever you wish, then create it.
- add a cpp file e.g. main.cpp
- fill main.cpp with the example:
#include "wx/wx.h"
class MyApp: public wxApp
  virtual bool OnInit();
  wxFrame *frame;
bool MyApp::OnInit()
  frame = new wxFrame(NULL, -1, wxT("Hello wxWidgets"), wxPoint(50,50), wxSize(800,600));
  return true;

- add a empty file and call it Makefile
- fill this file with:
hello: main.cpp
g++ main.cpp /*and here the output of wx-config as explained abow*/

- add a new target as "External Target"
- double click on the target to get the settings window and change the following
  o give a product name
  o Set the Directory giving the home of this project
  o close this window
- right click on the target and build it
- hopfully you'll find the executable in the home (project) folder (not possible to run from the gui)

My Makefile looked like that:
hello: main.cpp
g++ main.cpp -I/opt/local/lib/wx/include/mac-unicode-release-2.8 -I/opt/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__ -L/opt/local/lib  -L/opt/local/lib -arch i386 -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL -lwx_macu-2.8


More information:
admin / Dec 05, 2010
2004 - 2022 / lookass.ch