Creating the HelloWorld Project
In this guide, you will create a new C++ console application in Visual Studio, configure the paths for the INFINICAM SDK (PUCLIB) distributed as a ZIP file, and build a basic program that retrieves information from a GbE-2 (Ethernet model).
-
Create a new Visual Studio project
- Launch Visual Studio and select “Create a new project”.
- From the template list, select “Console App” (C++ / Windows / Console) and click “Next”.
- Enter a project name (e.g.
GbE2_HelloWorld) and click “Create”.
-
Change the build configuration to x64
Change the platform setting in the toolbar at the top of the screen from
x86tox64. -
Set the include path (C/C++)
Add the path needed to load the header files (
.h) from the extracted SDK.- In Solution Explorer on the right side of the screen, right-click the project name and select “Properties”.
- Set the configuration to “All Configurations” and the platform to “x64”.
- From the tree on the left, select “C/C++” > “General”.
- In “Additional Include Directories” on the right, add the path to the extracted
includefolder.C:\infinicam_sdk\include
-
Set the library path (Linker)
Configure the settings needed to load the SDK’s library file (
.lib).- From the tree on the left of the properties screen, select “Linker” > “General”.
- In “Additional Library Directories”, add the path to the extracted
lib\x64folder.C:\infinicam_sdk\lib\x64 - Next, select “Linker” > “Input” from the tree on the left.
- Add
puclib.lib;to the beginning of “Additional Dependencies”. - Click “Apply” > “OK” to close the properties screen.
-
Write the source code
Open the main file (e.g.
GbE2_HelloWorld.cpp) and replace its contents with the following code.#include <stdio.h>#include <stdlib.h>#include <PUCLIB.h> // Load the PUCLIB headerint main() {printf("Initializing INFINICAM GbE-2...\n");// 1. Initialize the SDKPUCRESULT ret = PUC_Initialize();if (ret != PUC_SUCCEEDED) {printf("Error: Failed to initialize the SDK. ErrorCode: %d\n", ret);return EXIT_FAILURE;}// 2. Search for a GbE-2 device on the networkPUC_DETECT_FILTER filter = { 0 };filter.nDeviceTypeFlags = PUC_DETECT_TARGET_GBE2; // Target GbE-2 devicesPUC_DETECT_INFO detectInfo = { 0 };ret = PUC_DetectDevice2(&filter, &detectInfo);if (ret != PUC_SUCCEEDED || detectInfo.nDeviceCount == 0) {printf("Error: No GbE-2 camera was found. ErrorCode: %d\n", ret);return EXIT_FAILURE;}printf("Detected a GbE-2 camera. (Devices found: %d)\n", detectInfo.nDeviceCount);// 3. Open the first detected devicePUC_HANDLE hDevice = NULL;ret = PUC_OpenDevice2(0, &hDevice);if (ret != PUC_SUCCEEDED) {printf("Error: Failed to open the device. ErrorCode: %d\n", ret);return EXIT_FAILURE;}printf("SUCCESS: The GbE-2 was opened successfully!\n");// 4. Example of retrieving camera informationUINT64 serialNo = 0;if (PUC_GetSerialNo(hDevice, &serialNo) == PUC_SUCCEEDED) {printf("Serial number: %llu\n", serialNo);}UINT32 version = 0;if (PUC_GetDeviceVersion(hDevice, &version) == PUC_SUCCEEDED) {printf("Device version: %u\n", version);}// 5. Close the devicePUC_CloseDevice(hDevice);return EXIT_SUCCESS;} -
Deploy the runtime DLL and run the program
- Press
Ctrl+Shift+Bto build the project. - Copy
puclib.dll(and its associated DLLs) from thebin\x64\folder of the extracted SDK into the same folder as the.exegenerated by the build (x64/Debugorx64/Release). - Connect the PC and the GbE-2 with an Ethernet cable, match the network settings (IP address, etc.), and press
Ctrl+F5(Start Without Debugging) to run the program. If the serial number is displayed in the console window, it has succeeded!
- Press
