Installing on Linux

We recommend that you install the drivers first, then the Kvaser CANlibSDK, and last install the hardware.

The latest versions of documentation, software and drivers can be downloaded for free at

Installing the Driver

System requirements:

  • Linux 2.6.29 or later
  • Header files and compiler for kernel compilation.
  • pkg-config

In Ubuntu e.g. installing header files is accomplished by issuing the command:

sudo apt-get install build-essential

On some systems you may need to install the Linux headers using something like:

sudo apt-get install linux-headers-`uname -r`
Having versions of the Linux headers installed other than that of the currently running kernel may cause conflicts and faulty drivers.
sudo apt-get install pkg-config

To download and unpack the latest drivers you may use:

wget --content-disposition ""
tar xvzf linuxcan.tar.gz
cd linuxcan
Choose a path that doesn't contain any spaces for CANlib to build properly.

Option 1. Manually build and install drivers

To build (compile) all drivers use:

It is advised to remove the old driver by calling sudo make uninstall before replacing the installed drivers.

To install all drivers, canlib and linlib use:

sudo make install

To install and load, virtual and PCI drivers:

sudo make load
Running sudo make load will also cause the virtual and PCI drivers to be loaded at boot time. This might be bad if experimenting with the device drivers.
It is never required to manually install or load any modules, create or edit files. This is taken care of the Makefile, in the root of the linuxcan directory.

Option 2. Build and install drivers using DKMS

Alternatively, drivers can be installed using DKMS which automatically recompiles and reinstalles the CANlib drivers after a kernel upgrade. In order to use DKMS, the same version of Linux kernel package as your kernel version needs to be installed. On Ubuntu, the correct kernel header version can be installed by:

sudo apt-get install linux-headers-generic

To install DKMS on Ubuntu:

sudo apt-get install dkms

To build a DKMS tarball, use:

make dkms

To add and install all drivers, canlib and linlib using DKMS:

sudo make dkms_install
Running dkms_install removes all previously installed CANlib DKMS modules for all kernel versions

To list all managed DKMS modules, versions and kernels within the tree as well as whether they have been added, built or installed, use:

$ dkms status
linuxcan, 5.38, 4.4.0-210-generic, x86_64: installed

The example output is taken from a computer running Ubuntu 16.04.7 LTS.

More information can be found in the included README file.

Installing Virtual Devices

The driver named "virtualcan" controls the Virtual Devices. The number of channels each Virtual Device has, and the total number of Virtual Devices, is controlled by editing define statements in linuxcan\virtualcan\virtualcan.h.

#define NR_CHANNELS 2
#define NR_VIRTUAL_DEV 1

Removing the driver

Option 1. Removing manually installed driver

To unload and uninstall all drivers, canlib and linlib:

sudo make uninstall

Alternatively, if there are multiple versions of the drivers installed, all of them can be removed using:

sudo make purge

Option 2. Removing drivers installed using DKMS

To remove the installed CANlib DKMS module for all kernel versions, along with canlib and linlub, use:

sudo make dkms_uninstall

Installing Kvaser CANlib SDK

System requirements:

  • The package libxml2-dev is needed in order to build kvamemolibxml.
  • The package zlib1g-dev is needed to build kvlclib.

To download and unpack the latest version of Linux SDK library use:

wget --content-disposition ""
tar xvzf kvlibsdk.tar.gz
cd kvlibsdk

To build everything, run


To run self-tests, run

make check

To install everything, run

sudo make install

Removing Kvaser CANlib SDK

To uninstall everything, run

sudo make uninstall