Samples C/C++¶
Prerequisites¶
- ctrlX WORKS
- ctrlX AUTOMATION App Build Environment
- ctrlX AUTOMATION SDK installed in the App Build Environment
-
ctrlX COREvirtual or ctrlX CORE
-
Visual Studio Code installed on your host computer
Visual Studio Code extensions (Install in SSH):
- C/C++ for Visual Studio Code (Microsoft)
- C/C++ Extension Pack (Microsoft)
- CMake Tools (Microsoft)
Find out the supported samples¶
Basic Samples¶
- Hello World recommendation -> start with this example
- Hello PLC
- ctrlX Data Layer Provider Simple
- ctrlX Data Layer Client Simple
- ctrlX Data Layer Client Subscription
- Diagnostics Logbook
- ctrlX Data Layer Diagnosis
Advanced Samples¶
- ctrlX Data Layer EtherCAT I/O's
- ctrlX Data Layer Shared Memory
- ctrlX Data Layer Provider All Data Types
- ctrlX Data Layer Client All Data Types
Debug and Run¶
- Build the executable via cmake plugin.
- Launch the app with the debugger attached by pressing F5.
Build and Install¶
- Launch Visual Studio Code as your IDE
- If the IDE is started remote connect via Remote Explorer extension to your builder environment (SSH target)
- Ensure that Visual Studio Code extensions "C/C++ Extension Pack" and "CMake Tools" are installed in your SSH target.
- Open the folder of the desired cpp sample under
samples-cpp/
Build a Snap¶
See Samples Overview
Important: Before building an arm64 snap run script public/scripts/environment/scripts/install-cpp-aarch64-libs.sh
once!
Create an Executable for Debugging¶
Select the CMake symbol in the sidebar, click '...' at the top of the explorer window and select 'Clean Reconfigure All Projects'.
Then make these settings in the status bar (blue area) :
- CMake (Current build variant): Select 'Debug'
- Active kit: Select 'GCC ... x86...'
- Select 'x64...' as build target
Click Build and observe the progress in the output window - the build process should finish without errors (exit code 0).
Now the executable for debugging is available in the subdirectory: generated/ubuntu22-gcc-x64/Debug/
To start debugging select 'Run and Debug' in the side bar, select 'x64...' as launch configuration an press F5 (or green start button).
The executable will be started and the debugger will set automatically a breakpoint at the beginning of the main() function.
Troubleshooting¶
All automatically created files are located in subfolders build
and generated
.
If there are unclear messages during the build process, it might help to delete the folders build
and generated
and restart the build process.
Support¶
If you've found an error in these sample, please file an issue
If you've any questions visit the ctrlX AUTOMATION Community