Compilation of VirtualBox add-ins for Ubuntu 9.10

I’ve been using the upcoming Ubuntu 9.10 installed as a guest system on VirtualBox for a while without any big problems. After one of big updates I found that currently under development 2.6.31 kernel version was installed. So, I decided to rebuild VirtualBox Guest Additions and it failed. Digging the logs helped me to find out what was the problem:

/home/mloskot/tmp/vbox/linux/module/vboxvfs/utils.c:423: error: implicit declaration of function utf8_mbtowc

Should be simple to fix. However, it seems that signatures of nls.h functions in the kernel have changed or have been moved to new place which I have no idea about. I’m not a kernel developer but I like to dig codes. Thus, I unpacked the VirtualBox installer, found the victim – utils.c and applied a very ugly fix:

extern int utf8_mbtowc(wchar_t*, const __u8*, int);
extern int utf8_wctomb(__u8*, wchar_t, int);

At least, it allowed me to compile and install the VirtualBox additions. I haven’t notice any run-time issues. I have reported this problem back to the VirtualBox as its code may need to be updated: #4823 (Missing declaration of utf8_mbtowc function in utils.c). So far, so good.

Similar stories

I’m a user of Pentax hardware and I like reading Joel Cornuzblog dedicated to Linux & Photography and Pentax too. I was amazed how similar Joel’s and mine Linux stories are:

I have also been using Linux for quite some years (starting in the days where having an up and running X server was a good week of hard work?) and have since then tried to use Linux for photography ? these days, I run Ubuntu for it?s ease of use.

I still remember the times when I was staying at my past employer office (nearly) every Friday overnight to download, install and learn Linux and programming. That days, I could only dream about broadband at home. The time is running so too fast!

libgeotiff lesson for today

Doing final tests of libLAS on Linux (Ubuntu 7.04), before Hobu will release 1.0.0, I attempted to build it with latest libgeotiff 1.2.5. I moved my fingers on keyboard and did ./configure && make, shortly then I saw strange looking error message:

/usr/bin/ld: makegeo: hidden symbol `__stack_chk_fail_local' in /usr/lib/libc_nonshared.a(stack_chk_fail_local.oS) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

Google is your friend, so in a few seconds I knew what’s going wrong. ./configure sets Makefile to call ld -shared. However, it does not work with GCC 4, because ld linker does not include all required references to other shared libraries. Simply, GCC linker driver seems to handle shared references better, than bare ld.

The conclusion is, that if you use GCC 4.x and you want to build libgeotiff, configure it this way:

./configure --with-ld-shared="gcc -shared"

Update July 31, 2008: Another solution is to add -fno-stack-protector option to CFLAGS and CXXFLAGS. Regarding Ubuntu Linux, this issue seems to be related to enabled SSP support (see also Ubuntu Wiki) available in GCC 4.1.