Introduction

Sane is the software that controls scanners under Linux. There are times that you need to build sane from source, such as when bugs are fixed or a new scanner support is added. This is a relatively advanced process for a new Linux user. Hopefully, this will be helpful.

The Procedure

Open a Terminal. You need some usb libraries, and compile and build software. Some backends use avahi to discover network scanners so type:

sudo apt-get install libusb-dev build-essential libsane-dev
sudo apt-get install libavahi-client-dev libavahi-glib-dev

Install git-core

sudo apt-get install git-core

Download the source code

git clone git://git.debian.org/sane/sane-backends.git

cd sane-backends

Discover where your existing sane is installed

sudo find /usr/lib -name 'libsane-dll.so'

The full path of libsane-dll.so is returned. For example "/usr/lib/i386-linux-gnu/sane/libsane-dll.so" Remove "/sane/libsane-dll.so" from the end and,when configuring, set libdir to the remainder of the path

./configure --prefix=/usr --libdir=/usr/lib/i386-linux-gnu --sysconfdir=/etc --localstatedir=/var  --enable-avahi
make
sudo make install

make takes a long time to compile all backends. If you only need a small number of backends you can speed up compilation by specifying those backends.

./configure --prefix=/usr --libdir=/usr/lib/i386-linux-gnu --sysconfdir=/etc --localstatedir=/var  --enable-avahi BACKENDS="kodakaio test"
make
sudo make install

will compile only the kodakaio and test backends.

Plug in your scanner and type

sane-find-scanner

and your scanner should be listed. Now try

scanimage -L
sudo scanimage -L

If your scanner is detected with both of these commands, you have a successful install. If it is detected with sudo but not as user, then you have a permissions problem. If it is not detected with either, see Troubleshooting below

Permissions

If you can scan as root, but not as user, you have a permissions issue. Current Ubuntu releases use udev to set permisions. Some previous releases used HAL. To edit udev:

sudo gedit /lib/udev/rules.d/40-libsane.rules

and add the following two lines(change the scanner name and usb product id and vendor id to match your scanner):

# Canon CanoScan Lide 100
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1904", ENV{libsane_matched}="yes"

Save the file, exit gedit and Scan Away.

Troubleshooting

If you follow the above instructions and cannot scan, there are several useful things you try.

First, check the file /etc/sane.d/<backend.conf>, where backend is the name of the backend that your scanner uses. Your scanner should be listed in this file, along with its usb id. If it is not listed, then add it, following the format that the other scanners use. In this example we are checking a scanner that uses the genesys backend.

cat /etc/sane.d/genesys.conf

A few of the older backends are deactivated by default. You can check for this by:

cat /etc/sane.d/dll.conf

and make sure that your backend is not commented with a '#'. If your backend is commented out, then delete the # with your favorite text editor.

Some additional commands that can be helpful are:

lsusb

Returns all usb devices

sane-find-scanner

Returns all attached scanners, supported or not

scanimage -L

Returns attached supported scanners

sudo scanimage -L

same as above, with root privileges.

scanimage -T

Runs a test of the scanner

scanimage -V

returns version of sane-backends

Updating sane-backends After Initial "git clone"

If you have previously cloned the source code and want to download the latest code, use the following:

cd ~/sane-backends
git pull

Then proceed with compiling sane as described above.

Compiled Sane without Configure Flags

Another problem that occasionally comes up is that someone tries to build the latest version of sane as described above, but they forget to add the recommended flags after the ./configure command.

--prefix=/usr --sysconfdir=/etc --localstatedir=/var

What happens is that Ubuntu ships with the sane libraries in /usr/lib/sane.

If you build sane from source with

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var

the new sane libraries will be installed over the previous ones in /usr/lib/sane.

But if you build sane with just

./configure

the new sane libraries will be installed in /usr/local/lib/sane.

To make sure that the newest version of sane (in /usr/local/lib/sane) is used

gksu gedit /etc/ld.so.conf

To use the old version it should read

include /etc/ld.so.conf.d/*.conf
include /usr/lib

To use the new version, change it to

include /etc/ld.so.conf.d/*.conf
include /usr/local/lib

Then run

sudo ldconfig

and you should be running the latest sane.

Additional References

CompileSaneFromSource (last edited 2014-09-22 22:37:09 by cpc1-bmly8-2-0-cust816)