How to Wrap Dynamsoft Linux Barcode SDK for Node.js

From version 4.x to 5.x, Dynamsoft improved Barcode SDK performance with a big leap. Unfortunately, only Windows edition is available for download so far. In this post, I will share how to create a Node.js extension with the preview version of Dynamsoft Linux Barcode SDK 5.2. If you are interested in Windows edition, please read – Building Node.js Barcode Addon with DBR v5.0.

Linux Environment: Ubuntu on Windows

If you are using Windows 10, Virtual Machine is not necessary for Linux development. I’d like to use the Linux subsystem installed from Windows Store:

Ubuntu on Windows


Environment Configuration

Open cmd.exe > bash. Install essential development tools ‘make‘ and ‘g++‘:

sudo apt-get install make g++

Download Node.js Linux binary (x64) and extract the package:

tar -xvf node-v8.4.0-linux-x64.tar.xz

Export Node.js bin path in ~/.bashrc:

export PATH=/mnt/f/zip/node-v8.4.0-linux-x64/bin:$PATH

Make the change work:

source ~/.bashrc

Extract dbr_linux_5.2.tar.gz:

tar -xvf dbr_linux_5.2.tar.gz

Create a symlink for

sudo ln -s <Your PATH>/ /usr/lib/

Install node-gyp:

npm install -g node-gyp

Node.js Extension

Let’s get started with binding.gyp:

    "targets": [
        'target_name': "dbr",
        'sources': [ "" ],
        'conditions': [
            ['OS=="linux"', {
                'defines': [
                'libraries': [

In this file, we define the module name, source code files, and libraries. To make -lDynamsoftBarcodeReader work, please ensure that you have generated the symlink (/usr/lib/ for beforehand.

Create The code is same to Windows edition.

Configure building environment:

node-gyp configure

Build the project:

node-gyp build

Import the module to Node.js app:

var dbr = require('./build/Release/dbr');
var fs = require('fs');
var barcodeTypes = 0x3FF | 0x2000000 | 0x8000000 |
                   0x4000000;  // 1D, QRCODE, PDF417, DataMatrix

function decodeFileStreamAsync(fileName) {
  let stats = fs.statSync(fileName);
  let fileSize = stats["size"];, 'r', function(status, fd) {
    if (status) {
    let buffer = new Buffer(fileSize);, buffer, 0, fileSize, 0, function(err, bytesRead, data) {
      dbr.decodeFileStreamAsync(buffer, fileSize, barcodeTypes, function(msg) {
        let result = null;
        for (index in msg) {
          result = msg[index];
          console.log("Format: " + result['format']);
          console.log("Value : " + result['value']);


Run a test:

node test.js -f test.tif

linux barcode sdk

How to Get the Linux Barcode SDK

Contact to get the download link.

Source Code