Please enable JavaScript to view this site.

IDS peak 2.7.0 / uEye+ firmware 3.31

If you use Visual Studio, you have several options to create a project:

Opening a C-Make project folder directly (from Visual Studio 2017 on)

Creating a Visual Studio project folder with CMake GUI (all Visual Studio versions)

Configuring a Visual Studio project folder manually

Opening a C-Make project folder directly (from Visual Studio 2017 on)

The CMake support is directly integrated since Visual Studio 2017. This way, you can open folders with a CMakeLists.txt file directly via "File > Open > Folder". You will find more information at https://docs.microsoft.com/de-de/cpp/build/cmake-projects-in-visual-studio. Select the appropriate Visual Studio version.

Start with a pre-configured CMakeLists.txt file from the examples. For this, copy e.g. the folder "<installation directory>/ids_peak/comfort_sdk/samples/source/c/walkthrough/" (comfortC) or ".../ids_peak/generic_sdk/samples/source/cpp/open_camera/" (genericC++) into your working directory. If desired, adjust the folder name and project name in the CMakeLists.txt file.

CMakeLists.txt

cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
 
project ("my_new_project")
 
message (STATUS "[${PROJECT_NAME}] Processing ${CMAKE_CURRENT_LIST_FILE}")
 
set (SAMPLE_TARGET_NAME ${PROJECT_NAME})
set (SAMPLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/output/bin")
 
# Generic c++
find_package(ids_peak REQUIRED)
 
# or comfort_c
# find_package(ids_peak_comfort_c REQUIRED)
 
add_executable (${SAMPLE_TARGET_NAME}
  main.cpp
)
 
# Generic c++
target_link_libraries(${SAMPLE_TARGET_NAME} PRIVATE ids_peak)
 
# or comfort_c
# target_link_libraries(${SAMPLE_TARGET_NAME} PRIVATE ids_peak_comfort_c::ids_peak_comfort_c)
 
set_target_properties(${SAMPLE_TARGET_NAME}
  PROPERTIES
      RUNTIME_OUTPUT_DIRECTORY "${SAMPLE_OUTPUT_PATH}"
)
 
// Copy DLL to output directory
# Generic c++
ids_peak_deploy(${SAMPLE_TARGET_NAME})
 
# comfort_c
#ids_peak_comfort_c_deploy(${SAMPLE_TARGET_NAME})

Alternatively, you can create an empty folder, copy the CMakeLists.txt file and customize the project name. In this case, you should create an empty main.c, main.cpp or Program.cs file next to the CMakeLists.txt.

1.Open the newly created folder in Visual Studio.

Fig. 256: Open folder (Visual Studio)

Fig. 256: Open folder (Visual Studio)

2.Test the configuration with the copied sample code or a short test code, e.g.

main.c (comfortC)

#include <stdio.h>
 
#include <ids_peak_comfort_c/ids_peak_comfort_c.h>
 
int main()
{
  peak_status status = peak_Library_Init();
  if (PEAK_ERROR(status))
  {
      printf("Library could not be initialized!\n");
      return 1;
  }
 
  printf("Library successfully initialized!\n");
  (void)peak_Library_Exit();
  return 0;
}

main.cpp (genericC++)

#include <iostream>
 
#include <peak/peak.hpp>
 
int main()
{
  peak::Library::Initialize();
  std::cout << "Library successfully initialized!" << std::endl;
 
  peak::Library::Close();
  return 0;
}

Programm.cs (genericC#)

using System;
 
namespace my_new_project
{
  class Program
  {
      static void Main(string[] args)
      {
          peak.Library.Initialize();
          Console.WriteLine("IDS peak Library successfully initialized");
          peak.Library.Close();
      }
  }
}

hint_info

Note on genericC++/C#

By right-clicking on the main.cpp/Program.cs in project folder explorer, define for this file "Set As Startup Item”. So the correct process is made known to Visual Studio to be able to start the execution automatically, e.g. for the shortcut F5.

hint_info

Note on genericC#

You may still need to correct the CMake generator. For this, open the CMake settings via right-click on the CMakeLists.txt file. Via "Show advanced settings", you have the option to change the CMake generator, e.g. to "Visual Studio 16 2019 Win64".

hint_info

Note on projects with Qt

If you have a project with Qt, correct the Qt5_DIR variable. See Notes on projects using Qt for Windows.

Creating a Visual Studio project folder with CMake GUI (all Visual Studio versions)

For all Visual Studio versions ≤ 2015 without direct CMake support, it is possible to create Visual Studio projects via the CMake GUI. Proceed as follows:

1.Copy one or more samples to your working directory for which you have write permissions.

2.Open the CMake GUI.

Fig. 257: Open the CMake GUI

Fig. 257: Open the CMake GUI

3.Specify the path to the folder containing the CMakeLists.txt file (1) and a build directory (2) for which you have write permissions.

Fig. 258: Specify paths and build directory

Fig. 258: Specify paths and build directory

4.Click on “Configure” (3).

Fig. 259: Select compiler

Fig. 259: Select compiler

5.Click on “Finish”.
Now CMake configures the project. For this, CMake searches e.g. the paths to the required components.

6.If not all components are found, an error message is displayed. Mostly, it is sufficient to click on "Configure" again. If you have a project with Qt , correct the Qt5_DIR variable, see Notes on projects with Qt for Windows.

7.Click on “Configure” again.

Fig. 260: Correct CMake configuration

Fig. 260: Correct CMake configuration

8.When CMake has found all the components needed, click "Generate" (4) to create the Visual Studio project. Afterwards the project can be opened directly in Visual Studio via "Open Project" (5).

The required project files are created in the build directory, including the Visual Studio Solution (*.sln). The source files (*.c, *.cpp, ...) are still located in the source directory (1).

© 2024 IDS Imaging Development Systems GmbH