UaModeler  1.2.0.214
 All Pages
HowTo (Linux): Compile the generated method project files

The generated code itself is identical for Windows and Linux; hence code that was generated under Windows can be used in a Linux SDK and vice versa. The integration of the generated code into your application strongly depends on the build environment you are using, e.g. Visual Studio, Eclipse, CMake, etc. This example will describe how to integrate the generated code into the delivered CMake files of the Unified Automation C++ SDK 1.3.2 in 6 simple steps:

Step 1: Adding files to your Build Environment

First, the generated source files must be added to the project. Make sure that the generated files are located in your application source folder. Open the related CMake file (here CMakeLists.txt in the folder sdk/examples/server_hello_world) and add the new *.cpp files starting with “newns_”:

Step 2: Include Header File

The generated header files must be included in the file servermain.cpp as shown below:

Step 3: Creating NodeManager Instance

Now, we create an instance of the NewNs::NodeManagerNewNamespace in the server startup and add it to the Server’s Nodemanager:

Step 4: Creating an Object Instance

In the start method of the server (servermain.cpp) the object must be instantiated and the node is added to the objects folder. After this step, the new object will be browseable and accessible in the server’s address space.

Step 5: Method Implementation (fktSum)

At last, the method has to be implemented in the file newns_myobjecttype.cpp.

Step 6: Compile and Run

To compile the project server_hello_world with the generated *.cpp and *.h files, just use the delivered buildExamples.sh script. You can also compile it in 64Bit mode using the script buildExamples64.sh.

If the compilation succeeded, you should find compiled application server_hello_world in release version or server_hello_worldd in debug version in the folder sdk/bin. Just start the application and connect to the server with Unified Automations UaExpert.

To check if the generated code works, just browse to the node MyObject and call the method fktSum.