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.