Sunday, January 17, 2010

installing rsdl on OS X i386 via rubygems

I was getting this problem trying to install rsdl, a wrapper program for ruby which initialises SDL/Cocoa:

Jehannum:SDL-1.2.14 oisin$ sudo gem install rsdl
Building native extensions. This could take a while...
ERROR: Error installing rsdl:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for ruby_sysinit()... no
checking for ruby_run_node()... no
creating Makefile
creating rsdl.c

make
gcc -arch ppc -arch i386 -Os -pipe -fno-common -I"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0" -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE -c rsdl.c
gcc rsdl.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch ppc -arch i386 -lruby -lpthread -ldl -lm -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -o rsdl
ld: warning in /usr/local/lib/libSDLmain.a, file is not of required architecture
ld: warning in /usr/local/lib/libSDL.dylib, file is not of required architecture
Undefined symbols for architecture ppc:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found for architecture ppc
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccEkUyfQ.out (No such file or directory)
make: *** [rsdl] Error 1


The solution was to add an ARCHFLAGS environment variable which stops it trying to build a ppc version:
Jehannum:SDL-1.2.14 oisin$ sudo env ARCHFLAGS='-arch i386' gem install rsdl
Building native extensions. This could take a while...
Successfully installed rsdl-0.1.2
1 gem installed
Installing ri documentation for rsdl-0.1.2...
File not found: lib

The "File not found" message at the end doesn't seem to matter.

It's handy that SDL, SDL_image and SDL_gfx seem to build and install the UNIX way (./configure && make && sudo make install) with no problems - at first I was worried by the lack of a .pkg installer for SDL but it seems to work fine so far. Cool!

Tuesday, January 12, 2010

Schneier: "Stop the Panic on Air Security"

A good article by Bruce Schneier on the tendency for overreaction to dramatic and rare events, such as hijackings and attempted underwear bombings, while ignoring far more common dangers which don't make the news headlines.

We're doing these things even though this particular plot was chosen precisely because we weren't screening for it; future al Qaeda attacks rarely look like past attacks; and the terrorist threat is far broader than attacks against airplanes.

We're doing these things even though airplane terrorism is incredibly rare, the risk is no greater today than it was in previous decades, the taxi to the airport is still more dangerous than the flight, and ten times as many Americans are killed by lightning as by terrorists.
...
We can see the effects of this all the time. We fear being murdered, kidnapped, raped and assaulted by strangers, when it's far more likely that the perpetrator of such offenses is a relative or a friend. We fear school shootings, even though a school is almost always the safest place a child can be. We worry about shark attacks instead of fatal dog or pig attacks -- both far more common. In the U.S., over 38,000 people die each year in car crashes; that's as many deaths as 9/11 each and every month, year after year.


Nothing he hasn't really said before, but well stated and all the more significant these days, given the hilarious ban on liquids and the ridiculous fiasco of Newark Airport being temporarily shut down and causing hours of delays because an innocent Chinese student crossed a laughable rope barrier to give his girlfriend a goodbye kiss.
Of course, instead of admitting that security was basically a joke (on the one hand, you're made to take off your shoes, be frisked, have your luggage X-rayed and possibly have someone examine your bits in a full-body scanner, then you enter the 'secure' area which is separated from the 'insecure' area by a cinema-waiting-line rope) and that they overreacted badly, New Jersey Sen. Frank Lautenberg stated that "what he did was a terrible injustice" to the thousands of people who were inconvenienced. Even though it was what airport security did that caused the inconvenience...

Let's stop the panic!

Thursday, January 07, 2010

No Nokia PC Suite on the Mac? Try Gammu!

With almost every mobile device I've had, the amount of freedom to run arbitrary software (especially software you've written yourself) has been low. Obviously needlessly low, too.
I once bought a USB datacable for my old Sagem X-5 to upload ringtones and Java programs without having to upload them to a webserver and download them with the Sagem over WAP/GPRS. I got ringtones working, but it turned out that it was impossible to upload Java programs over the cable.
Why? Well, there's no apparent technical reason for it - but it works out in the operator's favour, forcing you to download (from yourself) over their very expensive data service - at that time, it cost €0.02 per kilobyte with Meteor, which works out at €20.48 per megabyte, a shocking waste of money!

Similarly, when I bought my Nokia 6230i back in 2006, I soon discovered that while it could download Java applications with no problem, it was impossible to install them via its MMC card. The JAR/JAD would appear in its filesystem browser, but it would declare it an "unrecognised format".
Nokia did, however, release a package called the Nokia PC Suite, which was a reasonably comprehensive tool for doing lots of different things with the phone, including the installing of Java programs. And it worked via data cable and Bluetooth. Great!

Except that now, I don't have a Windows PC (at least, one with Bluetooth or a data cable). And it only runs on Windows (surprise!). My Macbook has built-in Bluetooth and can send files via the built in utilities, but the same "unrecognised format" issue pops up.

So that was the end of my frustrating search, until yesterday... enter Gammu!

This open-source program comes with a host of features for working with different types of phones, including my 6230i, and I was able to upload and install a Java application to the phone with Gammu over Bluetooth, finally!
What's the catch? Well... Gammu itself is a command-line tool so installing a program looks like:

Jehannum:Downloads oisin$ gammu nokiaaddfile Application Bart1.4
[snip debug warnings]
Searching for phone folder: *********
Information: Declared JAR file size is different than real. Fixed by Gammu.
Adding "Bart" version created by Bart
Writing JAD file: 100 percent
Writing JAR file: 100 percent


And Gammu uses a textual configuration file - mine looks something like:

Jehannum:~ oisin$ cat .gammurc
[gammu]

port = 00:16:BC:xx:xx:xx
model = 6230i
connection = bluerfphonet
synchronizetime = no
logfile = /Users/oisin/gammu.log
logformat = textall
use_locking = no


The port value can be found in Apple's "Bluetooth Explorer" in Devices->Show Device Discovery (cmd-D), under your phone's name (but replace the hyphens with colons).

Also you have to build the program from source which requires installing CMake and MySQL, but these have automated installers which caused no brainache. Getting Bluetooth to work required a small fix to one of the build scripts, but this has since been fixed so the latest version should work out-of-box.

So, if you have a Mac and a phone which requires Windows-only software to install applications, try Gammu.


. o O ( Now if I could only find a simple way to upload programs of my choosing to my iPod Touch without having to jailbreak the thing or pay Apple, again :/)