How to cross compile the Termcap library - Step by Step Guide

Introduction

This tutorial introduces the way to cross compile the Termcap library on an GNU Linux embedded platform. The host machine will be a PC on which a GNU Linux distribution is installed. The embedded platform might be constructed on top of one of the following architectures: arm, mips, mipsel, ppc or sparc.

The web site dealing with the Termcap library can be reached at the following URL: http://www.gnu.org/software/termutils/manual/termcap-1.3/html_mono/termcap.html

All the releases can be downloaded at the following URL: ftp://ftp.gnu.org/gnu/termcap

The latest available release at the time of writing of this tutorial is 1.3.1 (March 13th 2002). To download, it is enough to type the following command:

wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz

Overview

Termcap is a library and data base that enables programs to use display terminals in a terminal-independent manner. It originated in Berkeley Unix.

The termcap data base describes the capabilities of hundreds of different display terminals in great detail. Some examples of the information recorded for a terminal could include how many columns wide it is, what string to send to move the cursor to an arbitrary position (including how to encode the row and column numbers), how to scroll the screen up one or several lines, and how much padding is needed for such a scrolling operation.

The termcap library is provided for easy access this data base in programs that want to do terminal-independent character-based display output.

Prerequisites

To cross compile the Termcap library, you need either a cross compiler, or an emulated Linux running on top of a virtualization software such as QEMU, matching your specific target platform.

If you wish to build yourself such a cross compiler, you should read the crosstool tutorial. There you will find all the information you need in order to build a C, C++ 4.1 GNU compiler for an ARM platform.

If you prefer to setup an ARM Debian system on top of a traditional Ubuntun distro (after all you are an hacker, aren't you?), have a look at How to setup an ARM Debian on Ubuntu tutorial in this wiki.

In general, Termcap does not need specific dependencies.

Cross compilation process

Using a cross compiler

Assumptions

During the process, we will refer to the cross toolchain with xxx-yyy-linux-gnu prefix. For example, the C compiler is called xxx-yyy-linux-gnu-gcc. That is applied on all the tools and utilities such gcc, g++, ar, ld, etc.

We will also assume that bin, include, lib and libexec folders of the cross toolchain are accessible through the PATH variable environment in order to work with the compilers from any place in the file system.

Finally, we assume that it is intalled in the following folder:
/opt/crosstool/gcc-4.1.2-glibc-2.3.2/xxx-yyy-linux-gnu.

Organization

As mentioned above, the release being cross compiled is 1.3.1. The tar.gz file will then be extracted under the /opt/external_packages/termcap/1.3.1/source folder and the results of the compilation will be stored under the /opt/external_packages/termcap/1.3.1/compiled/xxx-yyy-linux-gnu folder.

The files resulting from the cross compilation are listed here:

.:
total 12
drwxr-xr-x 2 root root 4096 2008-03-04 15:13 include
drwxr-xr-x 2 root root 4096 2008-03-04 15:13 info
drwxr-xr-x 2 root root 4096 2008-03-04 15:13 lib

./include:
total 4
-rw-r--r-- 1 root root 1640 2008-03-04 15:13 termcap.h

./info:
total 164
-rw-r--r-- 1 root root  2097 2008-03-04 15:13 termcap.info
-rw-r--r-- 1 root root 47411 2008-03-04 15:13 termcap.info-1
-rw-r--r-- 1 root root 43853 2008-03-04 15:13 termcap.info-2
-rw-r--r-- 1 root root 49311 2008-03-04 15:13 termcap.info-3
-rw-r--r-- 1 root root 10452 2008-03-04 15:13 termcap.info-4

./lib:
total 24
-rw-r--r-- 1 root root 23796 2008-03-04 15:13 libtermcap.a

Cross compilation

Step 1

Install the termcap software by untaring it in the /opt/external_packages/termcap/1.3.1/source folder and then cd to this directory.

Note:

All the below directories and files must be moved from the termcap-1.3.1 folder to the parent folder (/opt/external_packages/termcap/1.3.1/source)

  ChangeLog
  install-sh
  termcap.c
  termcap.info-3
  tparam.c
  configure
  Makefile.in
  termcap.h
  termcap.info-4
  version.c
  configure.in
  mkinstalldirs
  termcap.info
  termcap.src
  COPYING
  NEWS
  termcap.info-1
  termcap.texi
  INSTALL
  README
  termcap.info-2
  texinfo.tex

Step 2

We will cross compile termcap with its default parameters so we will configure it by typing:
./configure --host=xxx-yyy-linux-gnu --prefix=/opt/external_packages/termcap/1.3.1/compiled/xxx-yyy-linux-gnu

Step 3

Once the Makefile is created, we need to edit it and apply the following changes:

CC = gcc
AR = ar
RANLIB = ranlib

becomes

CC = xxx-yyy-linux-gnu-gcc
AR = xxx-yyy-linux-gnu-ar
RANLIB = xxx-yyy-linux-gnu-ranlib

Step 4

To compile and install termcap, type successively make and make install. You should find the directories and files listed above under /opt/external_packages/termcap/1.3.1/compiled/xxx-yyy-linux-gnu.

Option II: Using QEMU

This section is not yet available.

Download

  • arm-termcap-1.3.1-tar.gz

You may consult this section if you want to download the Termcap library already cross compiled for your target platform if it is available. You can also contribute to expand the crosscompile.org community by uploading your own results in the case a given platform is not already supported.

Supported platforms

arm-unknown-linux-gnu


Written by David Sayada.

Edit History Last Modified March 10, 2008