Skip to content

ncc c quickstart

ncc c MyModel.NodeSet2.xml \
      --shortname mymodel \
      -e Opc.Ua.NodeSet2.xml \
      -o ./generated

This compiles MyModel.NodeSet2.xml into generated/mymodel.c and generated/mymodel.h. --shortname mymodel sets the filenames and initializer name. Replace the XML paths with your model and the standard OPC UA NodeSet; add further dependencies with -e as needed.

Use it with open62541

Compile mymodel.c with your application and make mymodel.h available to the compiler. After creating an open62541 server, call the generated initializer. This excerpt assumes server is an existing UA_Server *:

#include "mymodel.h"

/* During server initialization: */
UA_StatusCode status = mymodel(server);

Check that status is UA_STATUSCODE_GOOD before starting the server. On failure, delete the server instead of continuing startup. Load dependency models first: -e supplies XML for generation but does not add dependency nodes to the server.

The generated code needs a compatible open62541 SDK. Enable UA_ENABLE_XML_ENCODING to preserve initial values from XML; see runtime configuration. Regeneration overwrites the generated files, so keep handwritten code separate.

See CMake integration, datatype generation, or the command reference for details. For existing open62541 generator workflows, see the migration guide.