Mac Development / GCC

I have to do some task builds (is that what they call it on a Mac?). I have some instructions that include setting “environment variables” and “executing scripts” that look very much like Unix shell scripts. Eventually I will have to do builds using gcc. Can all of these things can be done on a Mac?

If we’re talking about MacOS X, yes. Under the hood it’s just BSD and your favorite shells and compilers are all there.

You may need to locate the install CD and install the Developer Tools if they’re not already on there though.

OK, try to locate developer tools, task #1.


To expand on friedo’s info…

If your MacOS X version is earlier than 10.4, then the Developer Tools will be on its own CD. If you have 10.4 though (“Tiger”), then the OS and Developer Tools are all together on one DVD. (Unless you ordered separate CDs from Apple, for a machine that doesn’t have a DVD reader, but that’s a rare thing.)

You can also download the Dev Tools from Apple’s ADC website, though to do so requires registration.

I did a bit of research on the Apple website. It looks like I will be able to run my Makefile(s) using bash and gcc right from the command line, at least I am hoping this is he case. I’m also using Qt for a GUI, they have a “configure” command that will create my Makefile(s) properly, hopefully. I have built this system on XP, Linux, and Solaris, so I’m hoping the Mac won’t be much more difficult than they were.

One sticky wicket we have is the discovery of dynamically mounted / dismounted USB disk drives. We have to implement a subsystem to notice when a new drive appears, and when an old drive disappears. Any ideas how to do this on a Mac?

Thanks again.

Have you checked Apple’s online developer site? I imagine there should be a device API call or three you can use to detect USB connect/disconnect events…

Yes, I do those very things all the time on my own machines. Bash is automatically installed no matter what (and it’s the default shell in MacOS 10.3 and later). GCC and Make are components of the Developer Tools, and probably won’t be present if someone hasn’t installed them yet.

I’d consider installing Fink or DarwinPorts for general Unix software management — not just for your current task, but for the future as well. They can make building third-party Unix tools a lot easier. I know Fink at least offers QT as one of their pre-configured packages. (That is, I see QT listed in their catalog; I’ve never used it myself.)

Fink also offers an “Aqua QT” package that is independent of X-Windows. I have no idea how well it works, but that sounds like a better choice if it’s equivalent. Some Mac users never install X on their machines.

You might have to cross your fingers and hope that QT provides some kind of disk mount notification, or else a way to bypass the normal event queue processing. I’d look in their documentation first to see how they implement event dispatching under MacOS X. Hopefully they do tell you something about this, somewhere.

Best case: they use the Carbon API and registered event handlers, or they use the Cocoa APIs, delegate objects, and overridden object methods. Worst case: they implement their own event loop; they receive disk mount events, and then ignore them, or call their own hard-wired handler. (I suppose “ignore them” counts as a hard-wired handler too, come to think of it.) If that’s their implementation, then you’re probably out of luck.

My armchair guess is that they’re using Carbon event handlers. If so, there are ‘kEventVolumeMounted’ and ‘kEventVolumeUnmounted’ events that you can request notifications for. These events don’t distinguish however between USB drives and any other kind, such as Firewire drives. You’ll have to check that device property yourself if you care about it.

There might also be some technique you could use based on the IOKit library, but I would be much less familiar with that approach. You’re entirely on your own if you go that route.