Building C++

Getting started with C++ always stopped at the build environment. I couldn’t get past it. I spend my days at a Powerbook. I like OS X, but I like open source more. I don’t want to wed a project to XCode. Getting started with C++ means casting about for a build tool.

I use Ant, and I don’t want to repeat that experience in a new project.

My problem with Ant is that it’s written in a language that is not turing complete (or is it? Proof?). You can respond to some changes in the environment, but it a pain, and hard to maintain.

So, I use Ant to run the build, but I layout the build using XSLT 2.0. I’m going to move to specifying the build in an Ant file that has additional namesapaces, so that it’s easier to get the output looking pretty. (Just decided.)

Ant is a weak DSL, and one that doesn’t offer a standard solution for writing build specific tasks. It’s like a Windows batch file, plus dependencies. You can write new Ant tasks, but this is involved. They have to be compiled as part of the build.

I’ve noted in a number of other posts that a language flourishes when it can be used to achieve small tasks, since it allows a program to snowball, and it gets the programmer hooked on the productivity.

There are three alternatives for me Rant, Rake, or A-A-P. Here’s where they stand.

  • A-A-P - The concept of recipes is appealing. If I want to build a GUI in C++, I’d like to have it generate OS X Bundles on OS X, and resource files on Windows, by specifying the source files and resources to a GUI recipe. This is how I see build systems.

    That is why Ant works as well as it does. The tasks available to Ant are recipes that generally do the right thing.

    Drawbacks for A-A-P are that it looks Python oriented, and I’m not up for learning Python. It says you can use Ruby. Good. But it has a domain specific language to structure the build, and looks involved, as if I’d learn a new language simply to use my build system.

    If I were up to that, I’d use Boost::Build, Jamboost, and Python, because in my C++ dreams visions of MPL dance in my head.

  • Rant or Rake - Either or, depending on what people on #ruby-lang tell me over the course of a few days.

    As said elsewhere, Ruby Forge is calling me. I miss CPAN. I miss honest opinions on what library to use where. I’m so worn out by Java’s proliferation of tools, libraries, vendors, fear, uncertianty and doubt.

    It may not have recipes, but maybe that’s a concept I can develop for Rant or Rake. Maybe the expressive power of Ruby will make that unnecessary.

    I’m asking about how this might be done on #ruby-lang and people are giving me baby talk answers, which generally means that I’m asking people how to do something in a way that doesn’t make sense. In Ruby you’ll probably brush these cares aside with a couple one liners.

  • This was a contemplative post that sat in drafts for a few days. I’ve decided on Rant as a build environment for the time being.

2 Responses to “Building C++”

  1. Firas Says:

    How is that C++ on XCode going? I’ve tried to get my had around it all - but I haven’t figured out how to write a graphical C++ program, only in the CLI. grrrr

    I did read about Carbon & Cocoa - but its all very confusing.

  2. Alan Gutierrez Says:

    Programming Carbon apps is not too difficult. It is a bit much to get started, but not anywhere near as complicated as the Windows GDI.

    There is plenty to read about at Apple, in their developer section. You basically register callbacks for events. You specify a function to handle an event. It is straightforward.

    Oh, and all your windows need to be declared in a special resource file called a NIB. I’m sure there is a way around that, but I didn’t bother.

    It will take a lot of code to make something really happen. I know that Cocoa is much easier than Carbon, but I’m not about to get into Objective C anytime soon.

    Cheers.

Leave a Reply