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:
- Open /etc/network/interfaces.
- 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:
- Open /etc/dhcpcd.conf.
- Add the static IP configuration:
interface eth0 static routers=192.168.8.2 static domain_name_servers=18.104.22.168 static ip_address=192.168.8.51
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:
This is the only method that needed to read the barcode image:
iRet = DBR_DecodeFile(pszImageFile, &ro, &paryResult);
Build the project:
cd samples/c make
Test it with a barcode image:
Pretty easy! If you are interested in the barcode SDK for Raspberry Pi, please contact email@example.com to get a trial version. The library libDynamsoftBarcodeReader.so is not publicly available yet.