1 # Copyright (c) 2019-2020 NVIDIA CORPORATION. All rights reserved.
3 @page dwx_hello_world Hello World Application
5 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
7 The following minimal tutorial will guide through writing and building your first NVIDIA<sup>®</sup> DriveWorks based application on a Linux desktop machine.
11 The first thing to do when building an application based on DriveWorks is to initialize its context:
13 dwContextHandle_t sdk = DW_NULL_HANDLE;
14 dwContextParameters sdkParams = {};
16 dwGetVersion(&sdkVersion);
17 dwInitialize(&sdk, sdkVersion, &sdkParams);
20 The header for the context can be included as:
22 #include <dw/core/Context.h>
25 Now we can for example figure out how many GPUs are available on the host machine:
28 dwContext_getGPUCount(&gpuCount, sdk);
29 std::cout << "Available GPUs: " << gpuCount << std::endl;
32 Last thing to do before exiting the program is to release the context:
37 For your reference this is what the full program will look like:
40 #include <dw/core/Context.h>
42 int main(int argc, char **argv)
45 dwContextHandle_t sdk = DW_NULL_HANDLE;
47 // instantiate Driveworks SDK context
48 dwContextParameters sdkParams = {};
50 dwGetVersion(&sdkVersion);
51 dwInitialize(&sdk, sdkVersion, &sdkParams);
53 std::cout << "Context of Driveworks SDK successfully initialized." <<std::endl;
54 std::cout << "Version: " << sdkVersion.major << "." << sdkVersion.minor << "." << sdkVersion.patch << std::endl;
57 dwContext_getGPUCount(&gpuCount, sdk);
58 std::cout << "Available GPUs: " << gpuCount << std::endl;
60 // release Driveworks SDK context
67 ## Building and Executing
69 This application can be built with gcc using the following command:
71 gcc -I/usr/local/driveworks/include/ -I/usr/local/cuda/include helloworld.cpp -ldriveworks -L/usr/local/driveworks/lib/ -lstdc++ -o helloworld
73 Afterwords when executing <b>./helloworld</b> you should get an output similiar to:
75 Context of Driveworks SDK successfully initialized.
79 @note An extended version of this hello world application is provided, for more information see @ref dwx_hello_world_sample.
80 @note For more complex examples please refer to @ref dwx_samples_section.