Friday, 15 April 2011

Getting Closer

There are a number of logical steps required to build an application that will run under OSX.

The most obvious is that you need to compile the code. There are some hidden gotcha's if you're not using xcode or projectbuilder, however.

In my previous entry I commented on my discovery that you need to add a flag to the compile and link options "-arch i386".

This has allowed the code to happily compile and link, but when the application is executed it starts in the background and refuses to come to the front. No menus, and seemingly unable to accept focus.

Todays discovery has been getting the application to accept focus, this needed further changes to the way that my codeblocks ide is set up, as well as adding a new application to my system.

The dylibbundler is the new application. The main page says that dylibbundler is a small command-line programs that aims to make bundling .dylibs as easy as possible. It automatically determines which dylibs are needed by your program, copies these libraries inside the app bundle, and fixes both them and the executable to be ready for distribution.

But like everything, it wasn't quite as easy as running the command line utility.

Firstly the output directory was changed to myApp.app/Contents/MacOS/myApp

Then I added the following to the Pre/Post build steps:

/Developer/Tools/SetFile -t APPL $(TARGET_OUTPUT_FILE)
/Developer/Tools/Rez -d __DARWIN__ -t APPL Carbon.r -o $(TARGET_OUTPUT_FILE)
/usr/local/bin/dylibbundler -od -b -x ./SRA.app/Contents/MacOS/$(TARGET_OUTPUT_FILE) -d ./myAPP.app/Contents/libs/

This now gives me a running application that can be brought to the front. Note that the text is wrapping, a copy/paste into codeblocks will help.

Now all I need to do is to get the code to load the text file and display correctly. That might just be a little more difficult than getting codeblocks and OSX to play nicely.

Update: a step I missed out was to set the Output filename for the build targets to point to the modfied file name. For my app I had to set it to bin/osx/Debug/Sim65.app/Contents/MacOS/Sim65.

Monday, 21 February 2011

Frustrations with computers

In my free time (hollow laugh), I'm looking at creating a couple of simple applications using Codeblocks and wxWidgets.

My primary development environment is a laptop currently running Ubuntu 10.10, but I was wanting to use the same tools on my MacBook running Snow Leopard.

Over the past few visits to Starbucks, I've been trying to get a default application from Codeblocks for wxWidgets to compile, and got some wonderful compile and link errors.

The problem, apparently, is that the compiler will generate 64 bit code by default, which does not seem to be supported by many libraries.

After much frustration, I pasted an entire line from the build log into Google, finding this site http://forums.codeblocks.org/index.php?topic=12968.0.

The recommendation is to add -arch i386 to both the compile and link options. And it seems to work.

At least now I have a custom compiled set of wxWidgets libraries and Codeblocks itself. Sigh.

Time to start cutting code.