View Full Version : build a 32 bit driver under 64

2nd December 2006, 02:29 PM
My host system is Fedora Core 6 (64 bit).

I am running a 32 bit application which needs a 32 bit chipcard driver. For the driver I have all the sources. My problem is, when I make a "configure->make->make install" I obviously get a 64 bit driver.

Can somebody explain me the way, how to build a 32 bit driver under a running 64 bit linux system?

Thank you in advance,

2nd December 2006, 04:03 PM
./configure --help

see if this offers any options

2nd December 2006, 04:20 PM
Thank you for that.

Are the flags "--build=" and "--host=" the right ones? But what do I have to insert there? "i386" ???

I will post the output:

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']

Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX

By default, `make install' will install all the files in
`/usr/local/towitoko/bin', `/usr/local/towitoko/lib' etc. You can specify
an installation prefix other than `/usr/local/towitoko' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data [PREFIX/share]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--infodir=DIR info documentation [PREFIX/info]
--mandir=DIR man documentation [PREFIX/man]

Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names

System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]

Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
card type (default=probe)
card convention (default=probe)
memory card type (default=probe)
memory card size (default=probe)
--enable-ISO-t0 transportation of APDUs by T=0 (default=no)
enable debug (default=no)
--enable-usb-bundle enable PCSC Lite USB bundle installation
--enable-devfs enable Linux 2.4.X devfs support (default=no)
--enable-devpcsc enable /dev/pcsc links support (default=no)
--enable-win32-com enable win32 style COM port numbering (default=no)
--enable-thread-mutex enable thread mutexes (default=yes)
--enable-atr-check enable checking of valid ATR (default=yes)
--enable-atr-timings enable decoding of timings from ATR (default=yes)
--disable-dependency-tracking Speeds up one-time builds
--enable-dependency-tracking Do not reject slow dependency extractors
--enable-static=PKGS build static libraries default=no
--enable-shared=PKGS build shared libraries default=yes
--enable-fast-install=PKGS optimize for fast installation default=yes
--disable-libtool-lock avoid locking (might break parallel builds)

Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pcsc-lite-dir PCSC Lite base directory (default=/usr/local/pcsc)
--with-gnu-ld assume the C compiler uses GNU ld default=no
--with-pic try to use only PIC/non-PIC objects default=use both

Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
headers in a nonstandard directory <include dir>
CPP C preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

2nd December 2006, 05:00 PM

./configure --build=i686

2nd December 2006, 05:16 PM
I tried that already.

It builds something, but when I try to test it (with an application which is also builded out of the chipcard sources) the test program gets an error. Without the build=i686 flag, the builded test program works fine with the builded chipcard driver.


2nd December 2006, 08:32 PM
Is it possible to load a 32bit kernel module in a 64bit kernel? I would say no. Did you try to compile the 64bit module load it and test the software? I guess it should work. 32bit nvidia libs work with 64bit nvidia module too.

2nd December 2006, 09:12 PM
I'm giong to have to back up Noneus. As far as I know, there is no way to load a 32bit module into a 64bit kernel or vice versa.

2nd December 2006, 09:15 PM
As far as I know, it's not possible to load a 32 bit module in the kernel. But what I would like to have, is to load a library in a 32 bit application. And because I compiled the library by myself, it's a 64 bit library. And that definitly doesn't work. The application doesn't understand the 64 bit driver. It says, that it's not a valid library.

2nd December 2006, 11:13 PM
You need special compile flags. Try these:
-march=i386 -m32

You need to tell the linker that it should create a 32bit binary
--format elf32-i686 -m elf_i386

4th December 2006, 06:22 PM
Thank you Noneus.

But I don't know how to tell the configure script the flags.

4th December 2006, 06:50 PM
export LDFLAGS="--format elf32-i686 -m elf_i386"
export CFLAGS="-march=i386 -m32"
./configure --your-configure-flags

If you don't have a configure script just use this for make:
make CFLAGS="-march=i386 -m32" CXXFLAGS="-march=i386 -m32" LDFLAGS="--format elf32-i686 -m elf_i386"

This should work.

4th December 2006, 07:17 PM
I get the following error after running the configure script:

[me@localhost towitoko-2.0.7]# ./configure --build=i686
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets ${MAKE}... yes
checking build system type... i686-pc-none
checking host system type... i686-pc-none
checking for gcc... gcc
checking for C compiler default output... configure: error: C compiler cannot create executables

5th December 2006, 08:47 PM

I just want to let you know, that I built the library in a virtual machine with Fedora Core 5 i386.
And it works.

Thank you Noneus, for your help.