Category Archives: mac
Mac vs Open Source
I develop software.
The kind of software I work on rarely concerns itself with details of the platforms it runs on, and is therefore inherently platform-neutral. Of course complete cross-platform compatibility is elusive, but one does one’s best to adhere to widely-supported standards, libraries known to be cross-platform, etc. And if something non-standard is unavoidable, try to package it so that switching it out will be clean and straightforward as and when someone has the need.
So it’s with some concern that I see the Mac platform apparently moving to distance itself from the open source world I inhabit. I’ve got used to the idea that I sometimes have to use clang instead of gcc, and that that gives rise to annoying gotchas when autoconf stuff picks up gcc/g++ in spite of the standard names cc, c++ et al all being the clang versions! Still, I guess it’s not the platform’s fault if
CC=cc CXX=c++ ./configure –options
Now it’s OpenSSL that’s been giving me grief. Working with it on Mac for the first time, I see all the OpenSSL APIs I’m using appear to be deprecated. Huh? Googling finds that the whole of OpenSSL is deprecated on Mac. Thou shalt use CC_crypto(3cc) instead! Damn!!
OK, what’s CC_crypto? Given that lots of software I work on uses OpenSSL, it’s only going to be of interest if it emulates OpenSSL (well, if for example it was an OpenSSL fork then that would be a reasonable expectation). There’s a CC_crypto manpage, and google finds similar information at Apple’s developer site, but therein lies nothing more enlightening than cryptic hints:
To use the digest functions with existing code which uses the corresponding openssl functions, #define the symbol COMMON_DIGEST_FOR_OPENSSL in your client code (BEFORE including <CommonCrypto/CommonDigest.h>).
The interfaces to the encryption and HMAC algorithms have a calling interface that is different from that provided by OpenSSL.
Well, if that means it’s mostly OpenSSL-dropin-compatible, why not say so? Even googling “CC_crypto openssl emulation” doesn’t turn up anything that looks promising, so I haven’t found any relevant documentation. And since the header files are different, it will at the very least require some preprocessor crap. OK, ignore it, stick to OpenSSL, kill off the -Werror compiler option, and maybe revisit the issue at some later date.
Not good enough. The build bombs out when something (not my code, and I’d rather not have to hack it) uses HMAC functions, whose signature on Mac is different to other platforms. So openssl on Mac – specifically /usr/include/openssl/hmac.h – is nonstandard! Grrr … In fact it appears to be some bastardised hybrid: OpenSSL function names with CCHmac-like declarations. Is this OpenSSL in fact a wrapper for CC_crypto? If so, why is it all deprecated? Or if not, who has mutilated the API?
Well OK, that’ll be what Homebrew was talking about when it flashed up some message about installing OpenSSL only under Cellar, and not as a standard/system-wide lib. So I have another OpenSSL. Perhaps more? locate hmac.h finds a whole bunch of versions (ignoring duplicates and glib’s ghmac.h):
Of those, only the Cellar version is compatible with the canonical OpenSSL. A –with-openssl configure option fixes my immediate problem, but throws up a bunch of questions:
- Why have I had to jump through these hoops?
- Where would I start if I want to use CC_crypto as advised in existing OpenSSL-using code?
- What do I need to keep up-to-date on my system? Presumably standard apps use the version in /usr , but is anything keeping that updated if homebrew isn’t touching it?
Dammit, looks like this Mac may be vulnerable! Everything in /usr/include/openssl is dated 2011 (when the macbook was new). The libssl in /usr/lib is dated September 2014 – which suggests it has been updated by some package manager. But it identifies itself as libssl.0.9.8, which is not exactly current. Maybe it’s a Good Thing the macbook’s wifi died, so it no longer travels with me outside the house.
WTF is Apple doing to us?
Where do I find lost files and mail settings on Mac?
OK, today the macbook lost my mail.
That is to say, instead of Mac’s mail client launching normally, showing me my folders and connecting to my servers, it gives me the setup wizard. It won’t even let me bypass the wretched wizard and launch the mailer.
OK, I haven’t lost anything irretrievable (except perhaps some long-forgotten drafts), but I’d really rather not do battle with that wizard again: so much frustrating guesswork to find the settings that’ll talk to imap and imaps servers. Are my settings somewhere I can retrieve them?
It’s at this point I realise how hopelessly irrelevant my Unix knowledge is when it comes to a Mac. There’s no lost+found directory. “ls -la ~ |grep -i mail” (and variants) turn up nothing. Neither does a look in Mac’s /Applications/Mail.app turn up anything that looks remotely promising.
More frustratingly, neither does Google. My attempts to google this question just turn up screenfuls of how to do things using the Mail GUI. The same mail client that refuses to launch without the ritual incantation of the setup wizard. Grrrr …
Dear lazyweb, Anyone know where in the mac filesystem I might look? MacOS announces itself as 10.7.5.
The apple in winter
I know I’ve blogged before about the macbook’s dead wifi. That’s now a worked-around problem: it generally serves as a desktop-substitute at the treadmill, where it can use wired networking. And if I want to use it elsewhere, I can connect it with USB+4G.
I don’t think i’ve ever troubled the blogosphere with a lesser but nevertheless very annoying problem: the macbook’s inability to hibernate in winter. I set it to sleep in the evening, then when I come back in the morning it’s unresponsive to anything on the keyboard, or any mouse click. Sometimes the screen is screwed too; other times it’s a perfectly normal but just unresponsive password screen. Nothing short of powering it down and hard reboot will revive it. That’s both frustratingly slow, and sits very poorly with the number of applications – particularly browser tabs – I keep alive. Past experience tells me this problem goes away with the warmer weather in spring, but not for quite a while.
Any tips for using a macbook in winter? Keeping certain apps open will prevent it sleeping so it remains warm and active indefinitely, but that goes against my principle of not wasting more electricity than a standby-state for overnight or longer periods.
Macbook wifi dying
Has anyone seen these symptoms? Googling gets me lots of networking issues all of which are rather different, and whose suggested solutions I had tried before googling.
The symptom: networking (over wifi) just stops working. The mailer sits and spins, or the browser times out trying to load a page. Same happens when I try the router’s page. Anything from the commandline hangs until DNS lookup times out. Meanwhile, if I fire up the other laptop it works just fine, indicating that the router and its outward connection are just fine.
Nothing too unusual so far. But trying to diagnose it, it begins to look like a hardware issue. It won’t “search for networks” as it normally would. And turning airport off, it simply can’t be turned back on: that is to say, I turn it on from – for example – Network Diagnostics – but it remains resolutely off. Similarly the networking wizard bombs out when it tries to activate airport.
So far the only solution I’ve found is to shut it down and restart from cold. But yesterday morning I did that and it lasted only ten minutes before dying again.
Anyone seen similar symptoms? Is there anything I can do to try and fix it?
After 7 years heavy use, my old macbook is showing its age. The battery has long been knackered: just about adequate to move the machine from one room to another and plug it in to the mains. The backlight failed last year and needs nursing to keep it working. And now the battery has reached a point where it powers down if I just accidentally knock the power lead out of place for half a second.
It’s been a good little machine and served its purpose: a laptop with a Unix-family OS and hardware that just worked. Plus a fantastic display quality that made a desktop substitute of the 13″ screen. It’s not been trouble-free: I had to replace the disc a while back, but on the whole it’s been great. But now with two major expensive-to-repair faults, I guess it’s time to look around the market again, and take advantage of other advances, notably further reductions in size and weight since 2006.
I don’t think I’ll go for another Macbook. My experiences with more recent macbooks have been rather less positive than the old one, while at the same time I’d expect there to be a much wider range of laptops where the more ‘challenging’ things of 2006 – like ACPI and builtin wifi – just work, without hassle.
So what’s a good laptop for Linux, or even with Linux preinstalled? Another 13″ screen will suffice provided the display is of comparable quality to the old Mac, and I’d love it to be genuinely small and light with a good battery life. That probably implies ‘ultrabook’. And since I’ll be doing lots of work with the GNU toolchain – which can write hundreds of thousands of tempfiles in a typical build – I can’t alas go for an SSD-only machine.
A bit of preliminary poking around suggests cheapo ultrabooks from Asus or Acer as good candidates with positive experiences from Linux users, and Lenovo and Toshiba as labels to avoid in the ultrabook space. Comments solicited from readers who know more than I: will a £500-ish ultrabook be a decent working machine, or is it likely to be as shoddy and useless as the Dell I had before the macbook? Anything in particular to look out for? Any further suggestions?
 Or I’d consider other-*X if someone convinced me it would be hassle-free on an appropriate piece of hardware.
Bootstrapping development on mac
I don’t have any strong memory of bootstrapping gcc on the old mac laptop. It’s something I just did, and I think it was by installing fink.
That’s not working on the new laptop: I’m getting an error message about needing version 10.7 or later of MacOS. Apple’s own xcode gives exactly the same. So it looks as if I’m going to have to get my hands dirty just to bootstrap a development environment.
MacOS on the machine identifies itself as version 10.8 (uname -a), so I infer that’s a misleading error message and may have nothing to do with the real reason the installers refuse to run. But of course in the absence of a compiler, I’m at the mercy of binary packages like these installers.
Googling hasn’t helped: all the results just tell me to install xcode. I have yet to try adding the specific error message (which I don’t have in front of me ‘cos I’m on a different machine right now), but I thought I’d try blogging just in case someone recognises the problem and can point me to an easy fix.
How do I bootstrap development on a new Mac?
Dear Lazyweb, how can I stiffen a laptop hinge, or prop it open?
I have a new laptop, from my new Lord and Master. Arrived today. It’s a 15″ MacBook Pro, which makes it not unlike a bigger, quieter, and updated version of my old macbook.
On the plus side are the reasons for getting a macbook: hardware that Just Works a whole lot better than other laptops I’ve encountered, and a unix-family operating system without having to install it over what the company supplied. On the minus side, several niggles, and one unexpected problem I’m scratching my head over.
The least of the niggles is that it’s US-oriented, with a US keyboard, and adapted for US power points: the latter makes it a pain to use here, though fortunately I do have a ‘universal’ adapter. Slightly more bothersome: the metal finish is rather unpleasantly cold to the touch while using it.
The big and unexpected problem is that the screen’s hinge is too loose. Not a problem when it’s resting on a flat surface, but it means I can’t hold it up vertically while lying on my back, a position I use quite a lot because it’s one I can sustain without back or neck pain. That’s going to make it particularly hard to travel with when I go to places that don’t have a desk and chair I can sit at for sustained periods.
Any suggestions for how I can get it to stay open appreciated.
Minefield File System
Just hit a nasty gotcha on Mac OS. Specifically 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386. The filesystem is schizophrenic over case sensitivity!
Of course we expect case-sensitivity in normal use. But watch:
$ scp remote:/path/to/File . File 100% 3086 3.0KB/s 00:00 $ scp remote:/path/to/file . file 100% 3757 3.7KB/s 00:00 $ ls File $ wc File 125 237 3757 File $
The second file has overwritten the first, and taken its name. Ouch!
Mac apps glitch
Dear Lazyweb, can anyone enlighten me?
Today I installed a web conferencing app on the Mac. It’s packaged the usual Mac way as a .dmg, but it was downloaded from within Oracle’s intranet. So I downloaded it to the OpenSolaris box (which has the VPN connection), then copied it across to the mac.
Click on the .dmg in finder? No use, it refuses to open, with an error message about no mountable volumes. Aaargh! Three minutes to the conference … think!
So I uploaded it to my webserver in public_html, and typed the new URL into Firefox. Now it loaded just fine! Into the web conference – and jolly glad I had the web part of it!
Any mac afficionados tell me why the .dmg won’t load from the local disc?
I’ve been struggling far too much this week with the Mac update. The local Mac shop was great: they got me the disc, then added a fresh MacOS Snow Leopard installation. However, that means I’ve been getting to grips with the quirks of another OS.
The biggest single hassle was networking: it always takes a long time and several tries to pick up my wireless network, and it pops up a little window on screen which won’t go away until I’ve retried half a dozen times and got a connection. That’s new: pre-update MacOS 10.4 networking “just worked” most of the time, and would be cured by a reboot when it failed.
At first when it kept failing, I thought there must be a problem with the signal, so I went through a lot of messing about, changing the SSID, the PSK, and trying with different forms of encryption and no encryption at all, and checking with the ‘phone that the router’s wifi was indeed working. This seems to me a major failing. It’s bad enough having to wait several minutes for a network, but I could live with that happening in background. But having the wretched thing pop up on screen any time I’ve been to the kitchen or bathroom and it’s suspended, and having to deal with it manually, is a major imposition on my time 😦
There are other things that pop up annoyingly on screen. When I ssh into my server (from the commandline in a terminal ferchrissake!) it opens a popup for my passphrase! On the plus side, the Mac terminal has finally acquired tabs, bringing it somewhere more like into line with KDE and Gnome terminals (KDE is still the best of the three, because I can use the tabs without messing with focus).
One more minor inconvenience: fink for snow leopard is not really ready. I installed it from source (the only available option), only to find it has only a tiny handful of packages, and nothing that I want from a package manager. So far I’ve installed gnupg ‘by hand’, and will get around to postfix real soon now.