Setting up (C++)
To start working with openDAQ™, the requisite binaries are required. They can be obtained at the openDAQ™ documentation and releases webpage. The binaries are currently available for Windows and Ubuntu (20.04 or newer).
-
Windows
-
Linux
To install openDAQ™, download the opendaq-2.0.0-win64.exe
installer, run it, and follow its instructions. Make sure
to add openDAQ™ to the system path to be able to run openDAQ™ application examples.
We recommend using the default installation path to avoid issues requiring additional environment variable modifications and troubleshooting.
To install openDAQ™ on Ubuntu 20.04 or newer, download the opendaq-2.0.0-ubuntu20.04-x86_64.deb
Debian package. Install it
using the following command:
sudo apt install ./opendaq-2.0.0-ubuntu20.04-x86_64.deb
Creating an openDAQ™ project
We start our project from the "quick_start_app"
example that can be found at the
openDAQ™ documentation and releases webpage. Download the examples.zip
archive and extract it to a folder of choice.
Requirements
-
Windows
-
Linux
-
CMake (3.20 or newer)
-
CMake generator and C++ compiler (Visual Studio 2022 is recommended)
-
CMake (3.20 or newer)
-
CMake generator and C++ compiler (g++ is recommended)
Run sudo apt install cmake build-essential to install the required tools.
|
Building the project
To build the project, navigate to the cpp/quick_start
directory and enter the following command
into a terminal or command prompt instance:
cmake -DCMAKE_BUILD_TYPE=Release -Bbuild .
With this, we are ready to start developing. We fill in our quick_start_empty.cpp
executable code as follows:
#include <opendaq/opendaq.h>
#include <iostream>
#include <thread>
int main(int argc, const char* argv[])
{
// Create a fresh openDAQ(TM) instance, which acts as the entry point into our application
daq::InstancePtr instance = daq::Instance(MODULE_PATH);
std::cout << "Press \"enter\" to exit the application..." << std::endl;
std::cin.get();
return 0;
}
When creating the openDAQ™ instance, we need to specify the root directory of our openDAQ™ Modules.
Conveniently, the CMake configuration pre-filled the correct directory into the MODULE_PATH
macro definition.
We now compile and run our program.
-
Windows
-
Linux
cd build
cmake --build . --config Release
cd Release
quick_start_empty.exe
cd build
cmake --build .
./quick_start_empty
If you managed to reach this point, you have successfully created your first openDAQ™ project! To find out more about using openDAQ™ applications to connect to, configure, and read data of Devices, continue with the openDAQ™ application quick start guide.
Troubleshooting
-
Windows
-
Linux
-
If, when running a CMake command, the following error is displayed: "`cmake` is not recognized as an internal or external command, operable program or batch file.", make sure that CMake is added to the
PATH
environment variable. -
If openDAQ™ is not found when running CMake, create a new environment variable named
openDAQ_ROOT
, with its value being the directory where openDAQ™ is installed. -
If the
.dll
shared libraries are not found when running the above example, add theopenDAQ/bin
folder path to thePATH
environment variable. Thebin
folder is located within the openDAQ™ installation folder. -
If no devices are found when discovering devices, check the
MODULE_PATH
variable if it points to the folder where modules are located. This is usuallyc:\Program Files\openDAQ\bin\modules
. If not, replace theMODULE_PATH
with folder string.
-
If the
cmake
command is not found, make sure that thecmake
executable is located in a folder that is included in yourPATH
environment variable. -
If openDAQ™ is not found when running CMake, export the
openDAQ_ROOT
variable to point at/opt/opendaq
(export openDAQ_ROOT=/opt/opendaq
). -
If the
.so
shared libraries are not found when running the above example, add/opt/opendaq/lib
to theLD_LIBRARY_PATH
environment variable (export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/opendaq/lib
) -
If no devices are found when discovering devices, check the
MODULE_PATH
variable if it points to the folder where modules are located. This is usuallyopt/opendaq/lib/modules
. If not, replace theMODULE_PATH
with folder string.