Requirements

Linux
x86 x64
Header files If_DBR.h
BarcodeFormat.h
BarcodeStructs.h
CommonConfig.h
ErrorCode.h
ExportDefines.h
If_DBR.h
BarcodeFormat.h
BarcodeStructs.h
CommonConfig.h
ErrorCode.h
ExportDefines.h
Lib Files libDynamsoftBarcodeReaderx86.so libDynamsoftBarcodeReaderx64.so

Three Steps to Get Started

  1. Suppose you are creating a project in a folder called test.

    Create a test.c file in folder "test" and copy the "Include" and "Redist" folders from the SDK package to "test"

    In the test.c, please include the .h files.

    Please replace <relative path> in the code with the relative path to the test.c file.
    #include <stdio.h>
    #include "<relative path>/If_DBR.h"

  2. In the test.c, please add the main function.

    Please update the <your image file full path> and <your license key here> with valid values respectively in the code.

    The licenses can be found in the [INSTALL FOLDER]/TrialLicense.txt.
    int main(int argc, const char* argv[])
    {
    	//Define variables
    	const char * strFileName = "<your image file full path>";
    	int iIndex = 0;
    	int iRet = -1;
    	pBarcodeResultArray pResult = NULL;
    
    	//Initialize license prior to any decoding
    	DBR_InitLicense("<your license key here>");
    
    	//Start decoding
    	iRet = DBR_DecodeFile(strFileName, NULL, &pResult);
    
    	//If error occurs
    	if (iRet != DBR_OK)
    	{
    		printf("Failed to read barcode: %d\n%s\n", iRet, DBR_GetErrorString(iRet));
    		return iRet;
    	}
    	//If OK
    	printf("%d total barcode(s) found. \n", pResult->iBarcodeCount);
    	for (iIndex = 0; iIndex < pResult->iBarcodeCount; iIndex++)
    	{
    		printf("Result %d\n", iIndex + 1);
    		printf("PageNum: %d\n", pResult->ppBarcodes[iIndex]->iPageNum);
    		printf("BarcodeFormat: %lld\n", pResult->ppBarcodes[iIndex]->llFormat);
    		printf("Text read: %s\n\n", pResult->ppBarcodes[iIndex]->pBarcodeData);
    	}
    
    	//Finally release BarcodeResultArray
    	DBR_FreeBarcodeResults(&pResult);
    
    	return 0;
    }
  3. Create a Makefile in the folder "test", replace <your project name> to test:
    ProjectName=<your project name>
    CC=gcc
    CCFLAGS=-c
    
    DBRLIB_PATH=./Redist
    LDFLAGS=-L $(DBRLIB_PATH) -Wl,-rpath=$(DBRLIB_PATH)
    
    ifeq ($(shell getconf LONG_BIT), 32)
    DBRLIB=-lDynamsoftBarcodeReaderx86
    else
    DBRLIB=-lDynamsoftBarcodeReaderx64
    endif
    
    STDLIB=-lstdc++
    
    TARGET=$(ProjectName)
    OBJECT=$(ProjectName).o
    SOURCE=$(ProjectName).c
    
    # build rule for target.
    $(TARGET): $(OBJECT)
    	$(CC) -o $(TARGET) $(OBJECT) $(STDLIB) $(DBRLIB) $(LDFLAGS)
    
    # target to build an object file
    $(OBJECT): $(SOURCE)
    	$(CC) $(CCFLAGS) $(SOURCE)
    
    # the clean target
    .PHONY : clean
    clean: 
    	rm -f $(OBJECT) $(TARGET)

    Please open a terminal, and navigate to the test folder to do the following to verify if it is working.
    $ make
    $./test