Archive

Archive for the ‘C++’ Category

Building Universal Binaries on MAC OS X with configure

May 8th, 2009

I recently ran into a ton of problems while trying to build the latest version of Remobo as a universal binary with OS X 10.4 support on my MacBook Pro running 10.5. In the end, all the problems were solved by passing in the right compiler flags and configure parameters. Here is a quick rundown of what I learned. Hopefully it will help someone out in the future!

Our project uses configure and automake etc… so we did not have XCode to help us with the settings. This will be true for many open source projects and libraries you come across since they are mostly written for Linux.

1) Make sure to pass the right compiler flags.

For a universal binary, use:
CFLAGS="-arch ppc -arch i386"
LDFLAGS="-arch i386 -arch ppc"

If you also want backwards compatibility with a previous version of OS X (10.4 in this example), use something like:
CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386"

This will compile using the 10.4 SDK instead of the default 10.5 since I am runnign Leopard.

2) Pass in the right configure parameters.

Make sure to add this flag to configure:
./configure --disable-dependency-tracking

This will ensure there are no problems when compiling for multiple architectures.

3) Check your output binary.

You can use the “file” command to make sure everything went according to plan. If the binary is truly universal, you will see something like this:
file ./src/hello
src/hello: Mach-O fat file with 2 architectures
src/hello (for architecture i386): Mach-O executable i386
src/hello (for architecture ppc): Mach-O executable ppc

Hope that helps!

One last tip: make sure all the dependencies and libraries you are using are also compiled in this way or else you will get link errors since the linker cannot combine regular binaries with universal binaries.

Gee C++, Remobo, Tips , , , , ,

wxWidgets GUI and Multiple Threads

March 26th, 2009

logo9This is an obscure tip, but if you are using wxWidgets as the GUI library in your application, this may come in handy. We currently use it for Remobo and it has served us well as a cross-platform GUI framework.  In particular we are using the C++ lib.

Never try to call any GUI related functions or even instantiate any wxWidgets GUI elements such as Frames and Dialogs from any other thread except the main one!

This is a documented caveat, but for some reason we thought it would be ok to just instantiate a custom wxDialog object in the secondary thread and leave the actual GUI calls to the main thread.  Turns out that even creating the object in a secondary worker thread will cause subsequent UI calls to hang indefinitely.  What made this worse is that it did not show up in MAC OS X but only on Windows…

We just spent a few days on this and it was impossible to find via regular debugging methods since the calls went deep into the Windows UI library… no fun at all. The solution is to call soemthing like wxPostEvent() to post some event from your secondary thread to the main thread and do all your wxWidgets stuff from there… including the wxWindow instantiation.

Gee C++, Remobo, Tips , ,

Remobo: a Computer Network for your Social Network

January 20th, 2009

Remobo LogoI thought I’d get things started on this blog by writing a bit about my current main project.  I’m a co-founder at AWIT Systems Inc. and we’ve created an application called Remobo.  The project itself has been going on for a few years now, but we are finally gaining some traction with a growing user base and have an idea of how we are going to monetize this thing.

What does Remobo do?

Remobo ScreenshotTo put it simply, Remobo simply creates a VPN between you and your friends, family, coworkers, etc.  This allows you to do things like share files privately, pay games across the Internet, remote control your home computer form work… basically anything you could do if you and your buddy were physically on the same LAN.

However, we like to think that Remobo is much more than just a VPN.  It provides a layer of connectivity beyond what your traditional social networks provide and anyone can just download it and be up and running in seconds since there’s virtually no configuration needed.  So we have changed our naming slightly and call it an IPN (instant private network).

On the tech side of things…

We use a P2P based architecture and the whole thing is written in C++ using libraries such as boost and wxWidgets.  Currently, its available for both PC and MAC OS X and we hope to have Linux available soon (it runs, but its not production ready yet).

So that’s the project I spend most of my time on… hopefully this is the year we make a breakthrough in the market and start earning some long awaited revenue.  In the future, I’ll post some of the technical issues and design choices we have encountered along the way.  We have a C++ guru on board at Remobo, so I’ll have to ask him to chime in sometime too :-)   I’ve mostly been coding the GUI and application side of things.

Gee C++, Projects, Remobo , , ,