Skip to content

Compiling and Installing on Unix flavors

Veronika Hanulíková edited this page Apr 3, 2024 · 1 revision

Compiling and installing on Unix flavors

The preferred method for using OpenSC on Unix is to use the pre-packaged versions from operating system vendor or distribution (see Linux Distributions, for example). If the version is older than the current version, first try to convince the vendor to upgrade the packaged version, if that's not a possibility, OpenSC can be easily built from source on any modern Unix.

Typical Installation

We suggest to install OpenSC into /usr and to put the configuration file into /etc/opensc. The default however would be /usr/local and /usr/local/etc, so you might want to change those. We suggest to configure and compile OpenSC like this:

tar xfvz opensc-*.tar.gz
cd opensc-*
./bootstrap
./configure --prefix=/usr --sysconfdir=/etc/opensc
make
sudo make install

Build Requirements

Installing Requirements on Debian/Ubuntu

sudo apt-get install pcscd libccid libpcsclite-dev libssl-dev libreadline-dev autoconf automake build-essential docbook-xsl xsltproc libtool pkg-config

If the certificates in the card are compressed, you also need zlib:

sudo apt-get install zlib1g-dev

If the driver for the card needs OpenPACE:

sudo apt-get install openpace libaec-dev

Installing Requirements on Fedora

sudo dnf install readline-devel openssl-devel libxslt docbook-style-xsl pcsc-lite-devel automake autoconf libtool gcc

If the certificates in the card are compressed, you also need zlib:

sudo dnf install zlib-devel

If the driver for the card needs OpenPACE, follow OpenPACE installation guide.

Build Configuration

OpenSC tries to auto-detect all libraries using the pkg-config system.

If you don't have pkg-config installed, and don't want to install it, you can use environment variables to tell configure, how to link with some library:

  • PCSC_CFLAGS and PCSC_LIBS for PCSC-Lite
  • OPENSSL_CFLAGS and OPENSSL_LIBS for OpenSSL
  • OPENPACE_CFLAGS and OPENPACE_LIBS for OpenPACE
  • READLINE_CFLAGS and READLINE_LIBS for GNU Readline

./configure --help will list other useful environment variables.

If some libraries are not installed in typical locations, you need to tell pkg-config where to find the *.pc files. You can do this with the @PKG_CONFIG_PATH@ environment variable, for example:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/mystuff/liv/pkgconfig

By default, we are compiling OpenSC with -Wall -Wextra -Wno-unused-parameter -Werror, which causes all compiler warnings to be treated as errors. Use ./configure --disable-strict to disable this behavior.

Clone this wiki locally