Simple ncurses Console Game

I wrote a simple ncurses game in C++ on Fedora.

I’ll actually be releasing the code and talking about how to build the game as part of a new Eclipse-C++ course I’m currently creating (sign up to my mailing list if you’d like updates on this).

It was pretty straightforward (once I finally got the ghost AI working properly – breadth first search anyone?). Ahem.

Anyway – here’s a little video I made of the game.

I cropped the screen area to get rid of distractions, which means the quality suffers a little bit, but you get the idea. And you’ve got to luuurve the cheesy music provided by iMovie…



How To Compile a 32-bit Executable on 64-bit Fedora 19

You know how sometimes you just have to compile and run a 32 bit program on a 64 bit machine, and it’s really annoying that it doesn’t seem to work?

Yeah, me too.

Turns out it’s actually pretty straightforward on Fedora 19.

First of all, you need to use the -m32 build flag. Below I’m using it to compile my program ‘pointers’:

gcc -m32 pointers.c -o pointers

You may run into the following error:

/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
# include <gnu/stubs-32.h>
compilation terminated.

To fix this you need to install the 32 bit glibc-devel package. You can do this by running:

yum install glibc-devel.i686

Next, you might see this error:

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.2/ when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

Which means you need to install the 32 bit standard C++ library package. You can do this by running:

yum install libstdc++-devel.i686

Then you can quite happily compile your executable with the -m32 flag, as above:

gcc -m32 pointers.c -o pointers

And, as if by magic, you get a 32 bit exe that runs on your 64 bit machine.

You can use the file command to admire what you’ve made:

[faye@localhost src]$ file pointers
pointers: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), 
for GNU/Linux 2.6.32, BuildID[sha1]=0x39958fed2f5c099ad97fd7512e780066acfb1231, not stripped

Sony Vaio No Touchpad Detected in Debian Squeeze

After 10 years on Fedora I have switched to Debian.

There isn’t really a definitive reason for the switch. It was partly that I didn’t really enjoy using FC16 at work and partly the negative reviews I read when looking to upgrade my own machine from FC14 to FC18. But it was also the fact that I just fancied a change.

I installed Debian two days ago onto my Sony Vaio and so far I like it.

However, out of the box my Vaio touchpad didn’t work.

It took me a while to find a fix, so this is what I did in case anyone else stumbles onto a similar problem.

In my case, the touchpad wasn’t being detected by the kernel at all (nothing in /proc/bus/input/devices and no relevant messages in dmesg).

Debian is a bit behind on the kernel – it uses 2.6.32-5.

But my original FC13 install on the Vaio used kernel 2.6.33 and the touchpad worked, so the first thing I did was update the kernel using the Debian backports.

I used a really nifty guide on nixCraft to upgrade to 3.2.0-0.

Once I’d rebooted I had a working touchpad, but no support for tap-to-click (and I love tap-to-click).

To get that working too, after enabling it in System > Preferences > Mouse [Touchpad], I used this solution to “Tap-to-click not working” on the Debian user mailing list.

For me, after rebooting again, tap-to-click and edge scroll were both working fine.

One happy new Debian user 🙂