Creating CDT projects for wxWidgets applications

From WxWiki
Jump to: navigation, search

This page will walk through coding wxWidgets applications in Eclipse CDT on mac OS X.


Creating the project

Start by creating a new CDT project in Eclipse like you'd usually do (File >> New >> C++ Project). Name it.

Setting up build options

  • Go to build options by right-clicking on the project and selecting Properties

We will be setting flags using Wx-Config. Notice how I use absolute path : adapt the path as needed to fit your environment. The factory OS X one will be at /usr/bin; yours will be in your build directory if you did not issue make install; if you issued make install after building wx, it will also be where you installed it (default being /usr/local/bin, like in the example below).

  • Setup build flags using wx-config

Eclipse cdt mac.png

    • Note : you may need/want to add some -arch i386 and/or -arch ppc and/or -arch x86_64 flags depending on how you built wx - especially on 10.6, where 64 bits vs 32 bits issues arise if you're not careful
    • Note 2 : note which configuration is selected (in the screenshots, it's "Debug"; you will probably want to change it to set settings for all configurations)
  • Setup linker flags using wx-config

Eclipse cdt mac2.png

That's it, you should be ready to add wxWidgets code and compile

Running the app

Notice that, by default, Eclipse CDT does not create app bundles, so your app will not be able to come into focus. See http://wiki.wxwidgets.org/WxMac_Issues#My_app_can.27t_be_brought_to_the_front.21 for solutions.

How to create the simplest possible app bundle in Eclipse CDT

  • Change the output location of your build target ("artifact") :

CDT AppBundle 1.png

  • You can have it create the app bundle automatically

CDT AppBundle 2.png

  • Also change your run config so it can find the executable in its new location

CDT AppBundle 3.png