How to Build C/C++ Barcode Reader App for Raspberry Pi

I have been playing Pi Emulator for a while. It is time to get my hands dirty on the real Pi device. In this post, I would share how to build my first C/C++ barcode reader application on Raspberry Pi.

Configure Static IP Address on Raspbian Jessie

By default, the Pi system configures DHCP for network access. In my company, I can only use static IP address, and thus, I have to manually set it up.

When searching Google for how to configure static IP address on Raspberry Pi, I found an answer:

  1. Open /etc/network/interfaces.
  2. Change “iface eth0 inet dhcp” to “iface eth0 inet static”.

The answer is correct but only works for Raspbian Wheezy, which is an older version of Raspberry Pi Linux OS. You don’t need to touch the file on Raspbian Jessie. Here is the right way:

  1. Open /etc/dhcpcd.conf.
  2. Add the static IP configuration:

     interface eth0
     static routers=
     static domain_name_servers=
     static ip_address=

Reboot the device to make the setting work.

Build Barcode Reader App on Raspberry Pi

Dynamsoft Barcode Reader is now available for Raspberry Pi. I made a little bit of change to the sample code that included in the SDK.

Copy source files to Raspberry Pi with SCP. Here is the project structure:

raspberry pi barcode project

This is the only method that needed to read the barcode image:

iRet = DBR_DecodeFile(pszImageFile, &ro, &paryResult);

Build the project:

cd samples/c

Test it with a barcode image:

./BarcodeReaderDemo ../../AllSupportedBarcodeTypes.tif

RaspberryPi barcode reader result

Pretty easy! If you are interested in the barcode SDK for Raspberry Pi, please contact to get a trial version. The library is not publicly available yet.

Source Code