xentropic-dev/zopcua
A Zig wrapper for open62541 that makes OPC UA development feel native to Zig through idiomatic patterns and abstracted C complexities.
A Zig wrapper for open62541, an open-source OPC UA implementation.
This library is under active development and NOT ready for production use.
This wrapper aims to make working with open62541 feel native to Zig by:
This library will not reach full feature parity with open62541 for some time. If you need functionality that isn't yet wrapped, please open an issue!
📚 View the full API documentation
Add zopcua to your project:
zig fetch --save git+https://github.com/xentropic-dev/zopcua.git
Then in your build.zig
:
const ua = b.dependency("zopcua", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("ua", ua.module("ua"));
zopcua requires mbedTLS for cryptographic operations and secure communication. By default, mbedTLS is statically linked from vendored sources - no system installation required.
If you prefer to use system-installed mbedTLS libraries instead:
const ua = b.dependency("zopcua", .{
.target = target,
.optimize = optimize,
.mbedtls = .system, // Use system mbedTLS instead of vendored
});
exe.root_module.addImport("ua", ua.module("ua"));
When using system mbedTLS, ensure the libraries are installed:
brew install mbedtls
sudo apt install libmbedtls-dev
const std = @import("std");
const ua = @import("ua");
pub fn main() !void {
var server = try ua.Server.init();
defer server.deinit();
try server.runUntilInterrupt(); // Blocks here until Ctrl-C
}
# Build the library (uses vendored mbedTLS by default)
zig build
# Build with system mbedTLS
zig build -Dmbedtls=system
# Run tests
zig build test
# Generate documentation
zig build docs
This wrapper library is licensed under the MIT License. See LICENSE for details.
The underlying open62541 library is licensed under the Mozilla Public License 2.0. See the open62541 repository for details.
Contributions are welcome! Please feel free to submit a Pull Request.