Internet on SE mobile from Ubuntu

After using my Sony Ericsson Yari mobile phone for a while I got disappointed from the slow response times. Using it for a while made the phone respond even slower in manner that wasn’t only annoying but also hard to use some times. I tried using lightweight themes and clearing the recent calls list but still the phone’s response time was really slow. I decided to try updating the phone’s firmware and see if there was any improvements on the performance.

My mobile contract didn’t include any Internet access plan, so I thought I could share my laptop’s internet access using my phone’s USB cable. After I connected my SE on my Ubuntu laptop a usb0 network interface appeared on my NetworkManager. After some trial and error I managed to share my internet connection with my mobile phone.

Here are the steps I followed:

  1. Right click on NetworkManager and select “Edit Connections”
  2. On the “Wired” tab select “Auto Ethernet” and hit “Edit”
  3. In “IPv4 Settings” select Method: “Shared to other Computers” and hit “Apply”
  4. On your Sony Ericsson mobile select: Settings -> Connectivity ->USB -> Advanced -> Internet access -> Via Computer
  5. You should be able to access the internet from your mobile phone using Ubuntu’s Internet connection.

After that I updated my phone’s firmware. Although I didn’t think it will help, my phone’s performance was significantly improved. I also noticed that the video recording shagginess issue was resolved too.

Cross Compiling in Ubuntu

I just got a fresh install on my laptop of Ubuntu 10.10 and I had to set some things up after restoring my backup files (long story). So I thought it’s a good chance to make some notes of the process.

I wanted to setup again my development enviroment for cross-compiling for w32 some C++ projects I like to develop. First of all I install MinGW on my Ubuntu installation.

sudo apt-get install mingw32

Happy to notice that there is a mingw-w64 package on the repositories, but I’ll have to try this another time.

It’s being a long time I’m trying to figure out a file structure on my home directory to keep the source code and cross-compiled libs in a seperate place for each platform. I decided to mimic the POSIX style. So I create a usr directory on top of my home directory and use local subdirectory for my current platform builds and w32 for the w32 platform. I was never sure what /usr/local meant on POSIX systems but this seems to work for me now 🙂


And now the first cross compilation must take place. I need to compile fltk2 with mingw32 for w32 platform. There is a nice README.mingw32_cross to help you with the process but it fails on some point. So I had to use an ugly work around to go on.

First of all following the README.mingw32_cross I ran a ./configure with the following arguments:

$ ./configure --build=i586-mingw32msvc --host=i586-mingw32msvc --target=i586-mingw32msvc --prefix=$HOME/usr/w32

And now for the ugly work around. I had to edit makeinclude with the following:

CFLAGS		= $(OPTIM)  -I/usr/i586-mingw32msvc/include
CXXFLAGS	= $(OPTIM) -I/usr/include/freetype2  -I/usr/i586-mingw32msvc/include -Wno-non-virtual-dtor

and fltk2-config accordingly:

# flags for C++ compiler:
CFLAGS=" -I/usr/i586-mingw32msvc/include"
CXXFLAGS="-I/usr/include/freetype2  -I/usr/i586-mingw32msvc/include -Wno-non-virtual-dtor"
LDFLAGS=" -L/usr/lib "
LDLIBS=" -L/usr/lib  -lXi -lXinerama  -lXext  -lsupc++

I’m almost sure there is a better way to do this, but I’m not really familiar with autoconf and configure tools. If someone has a neater solution please leave a comment.

And now run make.

The build fails but on fluid2 but it’s ok for me as long as the library gets compiled. Running make install will put my w32 cross compile fltk2 library in $HOME/usr/w32/lib

Wait a minute! I need some w32 cross-compiled SQLite for my Driver Study project. As I remember that will be easy.

Download the Amalgamation sqlite3 tarball extract it in $HOME/usr/w32/src, do some configuring, build and install:

$./configure --build="i586-mingw32msvc" --host="i586-mingw32msvc"  --target="i586-mingw32msvc" --prefix="$HOME/usr/w32"
$make install

And just worked.

Compile FLTK2 on Ubuntu

I’m using fltk2 for the development of DriverStudy. I had some difficulties compiling fltk2 on my Ubuntu, because of missing required libraries. So here are the packages you’ ll have to install to successfully compile fltk2.

sudo apt-get install xorg-dev libjpeg62-dev libpng12-dev

Instead of libjpeg62-dev you can install version 8 of the JPEG Library (libjpeg8-dev) if available on your system.

Also if you need OpenGL support on your fltk2 you’ll have to install GLUT libraries too.

sudo apt-get install libglut3-dev

The rest of the story goes like that:


After build completes take a look at test/demo for some demos.

Fish Identification Lesson

This weekend I had a trip back to my home town ( Komotini ), for fishing. Although the weather wasn’t friendly enough for the two of us ( myself & my father ), the sea was really generous.

On our less than 180 paternoster line ( παραγάδι ) hooks, we got at about 70 fishes of various species.

It was a great fish identification lesson and of course lunch for a week 😀

Create W32 7-Zip sfx in Linux

7-Zip tool

7-Zip allows you to create a self extracted binary archives with the -sfx switch. But in the Linux version of 7-Zip the SFX created is a Linux binary.

So if you run the following command in a Linux box and try to run test.exe in Windows you’ll get a “Program too big to fit into memory” error.

7z a -sfx test.exe test.txt

That’s because the binary is a GNU/Linux binary.

$ file test.exe
test.exe: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

The -sfx switch in Linux will try to use 7zCon.sfx module by default and will create a Linux binary console file.

If you want to create a W32 self extracted binary in Linux you have to pick the 7z.sfx module from the windows 7-Zip version and put it in the 7z directory.

In Ubuntu you can copy 7z.sfx in the following directory:


After done this you can use the -sfx7.sfx switch to create a W32 binary SFX file.


7z a -sfx7.sfx test.exe test.txt

and you get that

$ file test.exe
 test.exe: PE32 executable for MS Windows (GUI) Intel 80386 32-bit

stringify the result of expansion of a macro argument

To strignify a c/c++ macro’s argument you just have to add a leading ‘#’ in macro’s parameter.

#define STRINGIFY(s) #s

const char * thestring = STRINGIFY(50);

The preprocessor will expand this to:

const char * thestring = "50";

But if you try to pass a macro as argument to the STRINGIFY(s) macro, the macro argument will not expand to it’s value.

#define STRINGIFY(s) #s
#define VALUE 50

const char * thestring = STRINGIFY(VALUE);

will expand to:

const char * thestring = "VALUE";

That’s because stringification and concatenation use the argument as written, in un-prescanned form.

If you want to stringify the result of a macro argument, you have to use two levels of macros.

#define STRINGIFY(s) XSTR(s)
#define XSTR(s) #s
#define VALUE 50

const char * thestring = STRINGIFY(VALUE);

so, that will expand as:

const char * thestring = "50";

resource:  Stringification – The C Preprocessor

Invalid date because of DST

We are all familiar with the daylight saving time. Once every year we are happy that we earn a sleeping hour and once the exact opposite.

So what pushed me to blog about it?

squared circles - Clocks I had to hack a small bash script at work, so it will accept a date command line argument, to export that date reports. Piece of cake, right?

Done quickly with this simple hacking and thought to add some user input validation. Why not validate user input with the date tool? If date believes a date is invalid, then it is.

And ready to go! User request asked to use this small script and export for him three past dates reports.

  • 03/01/10
  • 03/02/10
  • 03/03/10

More valid dates than ever! Except from 03/03/10 that date believed it’s invalid!

How this can be possible! What’s so special about 03/03/10.

Googling around brought to my notice, that if you don’t specify to date that you want UTC ( -u ) it will work with your local system timezone and daylight saving times. So date 03/03/10 00:00:00 could really be invalid? It could if the DST for Eastern Standard Time was happening that day and time.

Although, this could be a great explanation for my problem, that wasn’t the case. I was using a really old version of cygwin’s date (probably not even a GNU version), that was just buggy and was reporting invalid date even with -u switch.

I may end-up in an dead end. But next I will be really careful when  using local times 🙂