Category Archives: Development

Development issues

Setup an Apache Pivot project in Eclipse

Apache Pivot logoApache Pivot is an open-source platform for building rich web applications in Java. I was looking for a modern UI toolkit and Pivot is exactly that. I’m willing to give a try so I tried to setup some Pivot projects in Eclipse. It actually comes with an Eclipse plugin that simplifies development of Pivot applications.

So here is a quick guide to setup Eclipse for the development of Pivot applications
Continue reading Setup an Apache Pivot project in Eclipse

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.

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 🙂

Web Develop or Just Browse with Firefox

Firefox Add-onsThere are two grate add-ons for Mozilla Firefox, that is a must for every web developer. I’m almost sure you know them.

Guessed right!

These are great tools even for non full time web developers. But they can impact your every day Internet browsing experience, by making Firefox more sluggish or just because they “pollute”  your beautiful interface. In other cases, everyday add-ons that make your browsing experience easier ( ads blockers, socialization stuff, … ) may harm your development process.

Considering all these, and because disabling each time the relative add-ons isn’t so convenient, I thought of using different Firefox Profiles for each job.

Profiles, are available from the early ages of Mozilla browser, but never found a reason to use it. It’s main reason of existence is to allow different users, use their own personal settings in the browser, but this is almost handled by OS’s multi-user capabilities.

What if the same person has multiple roles? Maybe a profile for each role could help.

  1. So, I popped up Profile Manager and created a new Development profile.
  2. Installed my development add-ons. Setup my interface and bookmarks to development needs.
  3. A special Firefox Developer shortcut.
firefox -p Developer -no-remote

That’s it!  A small inconvenience, of this setup is that if I run my Development profile Firefox first  and then try my default profile from it’s shortcut, a new Development profile Firefox tread will pop up. That’s because the default Firefox shortcut doesn’t use the -no-remote argument. But you can just add it your self 🙂

If only I could change my new profiles application icon  🙁

according to this, it doesn’t seem possible: