UaModeler  1.2.0.214
 All Pages
HowTo (Windows): 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 Visual Studio 2010 with Service Pack 1 in six simple steps.

NOTE To compile the server with Visual Studio 2010 SP1 you need to have the third-party files compiled with Visual Studio 2010 SP1 as well.

Step 1: Adding files to Visual Studio Solution

First, the source and header files generated in HowTo (Windows): Create a new project with a method have to be added to the Visual Studio project. Right click on the project and select Add → Existing Item. Then add all files starting with the prefix “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 press F7 (F6 in Visual Studio 2008). You can also compile it in 64Bit mode if all third-party files (like OpenSSL and LibXml2) are in 64Bit as well.

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 <Installation Directory>\UaSdkCppxyz\bin. Just start the application and connect to the server with Unified Automation’s UaExpert.

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