Static libraries into Shared One

When compiling several static libraries into one shared using Android NDK I ran into a problem and fixing it required changing the NDK.

Here is what the problem is. Let say I use this Android.mk:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mod1
LOCAL_SRC_FILES := libmod1.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mod2
LOCAL_SRC_FILES := libmod2.a
include $(PREBUILT_STATIC_LIBRARY)
#...more prebuilt static libs here...
include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_SRC_FILES := main.cpp
LOCAL_WHOLE_STATIC_LIBRARIES := mod1 mod2 <...>
include $(BUILD_SHARED_LIBRARY)

This won’t work in NDK 5 and 5b, specifically the macro LOCAL_WHOLE_STATIC_LIBRARIES won’t do anything.

This is how to fix it:

locate the setup.mk file you use, it’s one of those:

find -name setup.mk
./sources/cxx-stl/system/setup.mk
./toolchains/arm-eabi-4.4.0/setup.mk
./toolchains/x86-4.2.1/setup.mk
./toolchains/arm-linux-androideabi-4.4.3/setup.mk

In my case it was “./toolchains/arm-linux-androideabi-4.4.3/setup.mk”.

In that setup.mk locate defines cmd-build-shared-library and cmd-build-executable.

In these defines look at the call with $(PRIVATE_WHOLE_STATIC_LIBRARIES) as a parameter:

$(call link-whole-archives,$(PRIVATE_WHOLE_STATIC_LIBRARIES))

make sure that “link-whole-archives” matches the one in build/core/definitions/mk.

In my toolchain I had “whole-link-archives-tags” instead of “link-whole-archives”.

Happy Android hacking!

Scrum Rant

Well, not a rant, just an observation.

I do not understand why lots of companies these days are so obsessed with Scrum software project management development.

It is just one of many agile software development techniques, not better or worse than the others. For me personally it is actually worse, because I don’t like daily status meetings (in Scrum they call them “stand-ups”). I don’t like them for two reasons: I don’t feel comfortable standing up when there are sits available and don’t see a point of talking about my day over and over again.

As it looks to me, we have a substantial set of traditional, agile and lean development methods and principles, and selecting a right subset for a specific project and team is a matter of professionalism, experience and personal preferences.

I have always thought about agile software development as a rebellion for freedom. Freedom to choose and to use what fits and what works. When it becomes mainstream and takes a form of mandatory rules to follow, it defeats its purpose.

Install Virtual Box Additions on Fedora 14

I have been using Fedora 14 as my primary work desktop for a while. I like it a lot for many reasons and one of them that it easily runs as a virtual machine.

Oracle Virtual Box version 4 has been my choice for running desktop virtual machines because it is fast, robust, simple and free.

Anybody who runs Fedora knows it gets lots of updates and when such update includes the kernel then I have to reinstall Virtual Box Guest Additions that enable several important features with two I use all the time: mouse integration and shared folders.

This how to install or reinstall Virtual Box Guest Additions on Fedora 14.

First we need the kernel headers:

> yum install -y kernel-devel
> yum -y update

Then from the virtual machine menu, select Devices/Install Guest Additions and mount the image by selecting it from Fedora “Places” menu. Then run the Additions installer:

> cd /media/VBOXADDITIONS_4.0.0_69151/
> ./VBoxLinuxAdditions.run

Watch output for errors. That is it. Now you can use mouse on the virtual machine as it is your desktop extension and mount shared directories:

> /sbin/mount.vboxsf mydir /share/vbox/mydir

How to run Java samples from VMware SDK on Ubuntu 10.04

There are subtle differences in all Linux platforms and when I got to run VMware SDK Java samples on Ubuntu 10.04 I found there is something that is worth to share in addition to my first post about it.

First of all, there are very convenient “default” packages for JRE and JDK that have openjdk-6-jre and openjdk-6-jdk:

apt-get install default-jre defalt-jdk

Of course that means a different value for JAVAHOME:

export JAVAHOME=/usr/bin/openjdk-6/

Second, in my first post I did not describe how to get and store VMware server certificates.

If you follow the Setup Guild then you have to connect to a VMware server by SSH or use the vClient. But you can get the certificate from the Firefox browser: when connecting to a VMware server and asked to confirm the certificate, there is a button to export it. This allows to save the certificate locally and then add it to the keystore:

keytool -import -file XXX.XX.XX.XX.XX.cer -alias XXX.XX.XX.XX.XX \
-keystore vmware.keystore VMKEYSTORE=~/vmware-certs/vmware.keystore
export VMKEYSTORE

Also the tofrodos package has different name for the dos2unix utility, it is called fromdos now:

apt-get install tofrodos
cd %SDKHOME%\samples\Axis\java
fromdos *.sh

Unfortunately the axis binaries I still had to download manually.

HowTo: Install New ALSA Driver

During initial installation of Ubuntu 10.04 it detected my audio chip (integrated with my Gigabyte motherboard) without any problems, but after a couple of hibernations or for some other reason it lost it:

aplay -l
no soundcard found

I actually was surprised it found it at the first place as on any platform this kind of audio requires installation of hi-def drivers.

Anyway, first I tried to reload ALSA:

sudo alsa force-reload

It did not help.

Then after some digging I decided to compile and install the ALSA driver for my codec. My codec happened to be Realtek ALC888:

cat /proc/asound/card*/codec#* | grep Codec
Codec: Realtek ALC888

I got the driver from the Realtek web site.

Then untared, compiled and installed it:

tar xf LinuxPkg_5.15rc5.tar.bz2
cd realtek-linux-audiopack-5.15/
tar xf alsa-driver-1.0.23-5.15rc5.tar.bz2
cd alsa-driver-1.0.23/
./configure --with-cards=hda-intel
sudo make install

After rebooting got Rhythmbox loaded with Dire Straits and Tracy Chapman, sounds amazing.

Restore Vista MBR

When I removed a failed to load Kubuntu partition on my dual boot laptop, I did something stupid: I rebooted the computer.

Of course I ended up with Grub “Error 22”.

Fortunately I had a recovery DVD with system files and after booting from this DVD and getting into the command line, I found file bootrec.exe.

Executing it as:

bootrec.exe /fixmbr

restored the MBR and I was able to boot into Vista.

How to Assign Task Description

In one of comments the following code did not set a task description (shown in vSphere Client in Details column):

LocalizableMessage lm = new LocalizableMessage(); 
lm.setMessage(“Hello World”); 
myTask.getTaskInfo().setDescription(lm);

The problem is in missing key property of the newly created LocalizableMessage: it must be assigned from the task itself.

This is how it’s supposed to be done (Java):

LocalizableMessage lm = new LocalizableMessage();
lm.setKey(myTask.getTaskInfo().getKey());
lm.setMessage(“Hello World”);
myTask.getTaskInfo().setDescription(lm);

This is an example in C# (taskInfo is known value of Vim.TaskInfo type):

LocalizableMessage myDetailMessage = new Vim25Api.LocalizableMessage()
   { key = taskInfo.key, message = "my details" };
connection.Service.SetTaskDescription(taskInfo.task, myDetailMessage);

VMware Host IP Address

VMware host IP address is something of a phantom property: everybody knows it exists and use it all the time, but nobody knows where it is.

Well, this is probably because its location in the model changes depending on the host version and current network configuration.

This is how I get it.

1. For ESX systems, the system IP address is the IP address of the console, so its located at

config.network.consoleVnic["key"].spec.ip.ipAddress

where “key” is usually the only key in that collection.

2. For ESXi systems, the system IP address is the IP address of the HostVirtualNic class instance that is associated with the Management Network:

config.network.vnic["key"].spec.ip.ipAddress

where the “key” is the key of vnic that belongs to the management network portgroup.

Printing from Emacs on Windows

I’m a Emacs guy and this is how I got it printing on on of my Windows boxes (XP SP2) where I already had Cygwin.

1. Install PDF Creator.

2. Update .emacs file with the following:
(setenv "PRINTER" "PDFCreator")
(setq ps-printer-name "PDFCreator")
(setq ps-printer-name-option "-d")
(setq ps-lpr-command "/cygwin/bin/lpr")

3. Print into a PDF file with ps-print-buffer and then to any printer (or not at all).