Compiling and Compatibility

Compatibility

The CANlib API is designed to be upwards compatible; that is, an application written using a certain version of the SDK will run without modifications on a system where any newer version of the drivers are installed.

For example, if you develop an application using CANlib SDK version 3.7, the application will run without modifications on systems where driver 3.7, 3.8, ... is installed.

When you use the SDK to create an application, you use header files and import libraries. There's no need to recompile or relink your application if you want to run it on a system where a newer driver is installed. All runtime code is contained in the DLLs and the device driver files. The files in the SDK just contains API and constant definitions, and import libraries that reference the runtime DLLs.

In short, compile once, run anywhere!

Compiling and Linking Your Code

You will need to

#include kvmlib.h

in your programs and link with libkvmlib.so.

Note
libkvmlib.so is dependent on libkvamemolib.so and libkvamemolib0700.so.

Deploying Your Application

As an application programmer, you may want to distribute canlib32.dll together with your application. If you choose to do so, you should place it in the application's directory. In this way you will not break any other applications on the computer.

If you install canlib32.dll on the target system, and the rest of the device drivers are not installed, any call you make to canlib32.dll will return an error code. You should be prepared for this situation and handle the error code in a constructive way in your application. Another situation could be that the deployed application is using a new canlib32.dll function, as this also would require an update of the drivers it’s important to implement error handling in such a way that the application will inform the user to update their drivers.

A version mismatch between canlib32.dll and drivers will return the error code: canERR_DYNALIB, please see Error checking for further reading about error handling.

It is also possible to programmatically install the required device driver without user intervention.

Redistributable Files in CANlib SDK

The following files included in the CANLIB SDK may be redistributed with your application, provided they are only used together with genuine Kvaser hardware.

  • canlib32.dll
    API for CAN applications.
  • Kvaser.CanLib.dll
    API for CAN applications in the .NET environment.
  • sing32.dll
    API for emulating Softing's CAN API.
  • vcand32.dll
    API for emulating Vector Informatik's CAN API.
  • j1587lib.dll
    J1587 API DLL (for Kvaser Linx)
  • kv121032.dll
    RP1210A/B API DLL
  • kvj2534.dll, kvj2534c.dll, kvj2534i.dll
    SAE J2534 API DLL
  • linlib.dll
    API for LIN applications.

You may use and distribute the source code found in the SAMPLES directory in your own applications without restrictions.

Please contact Kvaser Support if you would like to redistribute any file not found in this list.