Requirements

Windows Mac
x86 x64 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
If_DBR.h
BarcodeFormat.h
BarcodeStructs.h
CommonConfig.h
ErrorCode.h
ExportDefines.h
Lib Files DBRx86.lib DBRx64.lib libDynamsoftBarcodeReader.dylib

Three Steps to Get Started [Windows]

  1. Create an empty Win32 Console Application project, through Visual C++ > Win32. Let's name it BarcodeReadDemo_C

    Add a new item main.c, please include the .H and .LIB files in it.

    Please note, the .H files can be found in [INSTALL FOLDER]\Include\, and the .LIB files can be found in [INSTALL FOLDER]\Lib\.

    Please replace <relative path> in the code with the relative path to the main.c file.
    #include <stdio.h>
    #include "<relative path>/If_DBR.h"
    
    #ifdef _WIN64
    #pragma comment(lib, "<relative path>/DBRx64.lib")
    #else
    #pragma comment(lib, "<relative path>/DBRx86.lib")
    #endif
    Please make sure the following .H files are in the same folder as If_DBR.h.
    BarcodeFormat.h, BarcodeStructs.h, CommonConfig.h, ErrorCode.h, ExportDefines.h
  2. In the main.c, please update 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]\LicenseManager.exe.
    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. Build the application, and copy the DynamsoftBarcodeReaderx86.dll, DynamsoftBarcodeReaderx64.dll, DynamicPdf.dll and DynamicPdfx64.dll to the .EXE folder. The DLLs can be found in [INSTALL FOLDER]\Redist\C_C++\.

    To verify if it is working, please open the cmd.exe, and execute the .EXE with a barcode image.

    To deploy your application, please make sure the DLLs are in the same folder as the EXE file. If your barcodes are from PDF files, DynamicPdf.dll and DynamicPdfx64.dll are mandatory.

Three Steps to Get Started [Mac]

  1. Create an Command Line Tool project, through XCode > C. Let's name it BarcodeReaderDemo_C

    In the main.c, please include the .H files and add the .DYLIB files.

    Please note, the .H files can be found in [INSTALL FOLDER]\Include\, and the .DYLIB files can be found in [INSTALL FOLDER]\Redist\.

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

    Please make sure the following .H files are in the same folder as If_DBR.h.
    BarcodeFormat.h, BarcodeStructs.h, CommonConfig.h, ErrorCode.h, ExportDefines.h
  2. In the main.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]\BarcodeReaderTrialLic.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. Debug or Run the code to verify if it is working!