Building SANE for OS/2

Here some information how I managed to build SANE 1.0.13 for OS/2. Perhaps there are other configurations that work. Setting up a build environement for unix-ports is not so easy, but things are improving. If you need help, there's also a unix-os2-mailing list where you might get support.

First of all you need the sources of SANE which you can get either (if you have installed CVS) for example with the following getsane.cmd

REM cvs login
REM Just hit enter
cvs -z3 co sane-backends
cvs -z3 co sane-frontends

When executing this command script for the first time you have to remove the first REM.
If you don't want to install CVS, since May 2003, the Sane 1.0.13 sources are also available as sane-backends-1.0.13.tar.gz and sane-frontends-1.0.11.tar.gz from
If you want to compile CVS-version instead of the tar-balls you have to replace
in description for the necessary small patches described later.

You need all those fine tools for porting 'unix-like' applications. Here is a list, that should work, maybe there are newer versions of some tools available on unixos2, that also work.
toolsavailable for example at
emx gcc compilerLEO / Hobbes
gnudiff, gnufutilsLEO / Hobbes
preferable this version of sh.exe
sedthe hompage of SAWATAISHI JUN
gettext 0.10.35 or later
latex (for parts of the documentation)
libsavailable for example at
If you want to compile xcam and xscanimage you need additionally
some gnome/gimp libsChristoph's Pages
tell me what's missing

The version of sed that works for me (and others) is sed version 3.02.80  which can be found as RPM-package on the hompage of SAWATAISHI JUN, the author of os2unix. You need RPM for OS/2 to install it, which is available on the same site. This version of sed  needs intl_d.dll  which is part of available from the
It also has been reported, that printf  (the version I use reports: printf - GNU sh-utils 1.12 ) which is called from libtool and generates the *.def files does not work with all versions of sh.exe . The sh.exe  which works for me is part of pdksh-5.2.14.

(It's also possible to compile with gcc 3.2.1. The result works for me (Epson, Mustek), but doesn't work with Scanmaker 630)


  1. Make shure that /emx/bin/install.exe is executed if you type install on a command-line
    (Rename OS2/INSTALL/install.exe or modify the PATH - Variable)
  2. Copy emx/bin/cp.exe to emx/bin/ln.exe
  3. Remove the line containing:
    #warning <sys/socket.h> requires <sys/types.h>
    from .../emx/include/sys/socket.h
  4. You need CONFIG_SITE defined. Example:
    SET CONFIG_SITE=g:/usr/share/
    either in config.sys or in the build script you use. And it should have reasonable entries at least for CFLAGS and LDFLAGS
    The values I used:
    • CFLAGS='-D__EMX__ -DOS2 -Zmtd -D__ST_MT_ERRNO__ -O2'
    • LDFLAGS='-Zexe -Zmtd -D__ST_MT_ERRNO__ -Zsysv-signals'
    You will find a reasonable template for in the os2unix-tool or in a recent autoconf-package from HOBBES
  5. (Optional) If you want to use the generated localisation-files (usr\share\locale\foo\LC_MESSAGES\ with X-frontends you have to convert them from UTF-8 to iso-8859-1 for example, because the available gtk (gimp-tool-kit) version 1.2 for OS/2 does not support UTF-8

libsane.dll, scanimage.exe, sane-find-scanner.exe, gamma4scanimage.exe and umax_pp.exe

  1. Optionally you can remove support for scanners you don't need to make compiling faster and libsane.dll smaller.
    For this purpose you have to modify sane-backends-1.0.13/backend/ and remove the scanners you don't need from the list which starts with:
    If you want to use saned or use a scanner over a network, don't remove net
  2. In ...\sane-backends directory:
    sh configure --prefix=/usr --enable-translations --disable-parport-directio
    ( '--enable-parport-directio' is only needed to support umax-parallelport-scanners)
  3. Replace sane-backends-1.0.13/libtool  with this modified version of libtool .
    You have to modify the lines containing
    to match your drive-letter/path. This are probably the only things you need to change.
  4. make
  5. make install
  6. Copy sane-backends\frontend\.libs\*.exe to \usr\bin
  7. Copy sane-backends\tools\*.exe to \usr\bin

I have scripts which do all steps from 2 to 8. You can get them by request.

The version build this way works perfect here with my EPSON GT-9500 and my Mustek 600S/600 II CD Scanner on OS/2 (eCS 1.0.1) with beta9 of aspirout.sys from Paul Ratcliffe.

Scanners that might work:
abaton agfafocus apple artec as6e avision bh canon coolscan dc25 dc210 dc240 dmc epson fujitsu hp leo matsushita microtek mustek mustek_pp nec net pie plustek qcam ricoh s9036 sceptre sharp sp15c st400 tamarack teco umax

You can also enter your scanner model into the Sane-Search-Engine and see whether your scanner is supported by the current version of SANE.

In general USB Scanners won't work on OS/2 because until now nobody has ported libusb to OS/2. I can't do this because I don't have time/USB-Scanner/USB-knowledge to do this job. Volonteers? Have a look at netlabs for a start.
But there is an exeption for Epson-USB-Scanners.
Some are supported by a SANE-binary compiled by Maeda Haruyuki! The binaries are part of the latest TAME Package (0.98 or later).

Parallel-Port-Scanners: I have one positive feedback for a Medion (Mustek)-Parallelport-Scanner, so in theory some might work, but support for umax-pp scanners is not compiled in into this binary-package because it causes a nasty delay of some seconds for searching such a scanner for all other users and previous binaries with included umax-pp support never worked anyway.

Additional Information and some SANE-betas (especially useful for snapscan-scanners) can be found on the Homepage of Paul Floyd

For questions and suggestions there is the OS/2 SANE Mailing-List

xscanimage.exe, xcam.exe and scanadf.exe

It is also possible to build xscanimage.exe, xcam.exe  and scanadf.exe  if you have installed the necessary libs.
  1. Include
    SET GTK_CONFIG=G:/XFree86/bin/gtk12-config
  2. Add -lpthreads to the 'echo line' near the end of /XFree86/bin/gtk12-config
  3. I had to delete the struct timespec definition from pthread.h  because this definition is allready in sys/time.h
Then I used the following steps:
  1. sh configure --prefix=/usr --with-sane-prefix=/usr --disable-sanetest --with-gtk-prefix=g:/XFree86 --disable-gtktest --disable-gimp
  2. In sane-frontends-1.0.11/src/Makefile 
    add to
    LIBS = -lsyslog -lsocket -lm
    the following code (one line):
    $(INSTALL_PROGRAM) $${program} \
    $(bindir)/$${program}; \
    $(INSTALL_PROGRAM) $${program}.exe \
    $(bindir)/$${program}.exe; \
  3. make
  4. make install

I have scripts which do all steps from 1 to 4. You can get them by request.

xscanimage.exe and xcam.exe are working on my system, I don't have a document-feeder so I can't tell ifscanadf.exe works, but it should.
If you configure with ... --enable-gimp
(and rename -lgimp to -lgimp121 in the Makefile) you get a xscanimage.exe that works for me as gimp(1.2.2)-plugin.


Here is the description how I did get the modified libtool  which was necessary to build libsane.dll .
I installed the source of SANE Version 1.01 and applied the patches from Yuri Dario included in his 1.01 binary distribution. All steps including autoconf and configure.os2. See his docs.
These steps created a reusable libtool.
I copied this so created libtool  to the 1.0.13 sane-backends-1.0.13/ directory and modified one line:
I inserted ../sanei/libsanei.a -ljpeg -lsyslog
between $objdir/$libname.def and -lsocket -s
in the line starting with
archive_cmds='$echo "LIBRARY


One powerful frontend for sane is xsane. You can find the informations how to build this program for OS/2 and a compiled version here.

Binary Packages

You also need a jpeg.dll if not already installed on your system.

Hardware that has been reported to work with previous binaries available from my site:
Hardware that has been reported to work with this version:

Thanks to Henning Meier-Geinitz, Oliver Rauch, Stéphane Voltz and Gerhard Jaeger who were very responsive in the sane-devel mailinglist and included some changes to the sources to make SANE 1.0.13 compile on OS/2
Thanks also to Paul Smedley and Zsolt Kadar who reported their experiences with this receipe for building SANE and helped to improve this page.
Thanks also to Paul Ratcliffe for aspirout.sys and Klaus Staedtler for TAME and testing and Thanks to all who reported if the binaries worked for them or not.
I hope I did not miss something important. Feel free to send me your comments.


Last modified 4 April 2006

Valid HTML 4.01