Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions devOpcuaSup/open62541/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Please contact the authors
(v1.2 and v1.3 series have been tested; their system packages should also work.
open62541 v1.4 changed the header file structure and does not work yet.)

* Cmake (3.x) if you're building Open62541 from sources.
* cmake (3.x) if you're building Open62541 from sources.

* For OPC UA security support (authentication/encryption), we suggest using the openssl plugin for Open62541. For that to work, you need openssl on your system - both when compiling the client library and when generating any binaries (IOCs).
On Linux, the name of the package you have to install depends on the distribution: development packages are called `openssl-devel` on RedHat/CentOS/Fedora and `libssl-dev` on Debian/Ubuntu, runtime packages are called `openssl` on RedHat/CentOS/Fedora and `libssl` on Debian/Ubuntu, respectively.
Expand All @@ -32,11 +32,25 @@ The Open62541 project is focused on the server implementation of OPC UA.
The client functionality is fully supported, complete and usable,
but it does not get the attention that the server parts get.

### On Linux

#### Using the Install Script

You can use the `install_open62541.sh` script to automate the build of the open62541 library.
The script will:

1. Download an appropiate version of the `open62541` source code
2. Build `open62541` as a static library with security support
3. Create the corresponding `CONFIG_SITE.local` configuration

**Please note**: This requires `curl`, `cmake` and the `openssl-devel`/`libssl-dev` library to be present. For support of structures also `libxml2-devel` / `libxml2-dev`
is required.

#### Manual Way

Do *not* use the download link on the open62541 web site.
Use their GitHub Release Page instead.

### On Linux

* Unpack the open62541 distribution. Create a build directory on the top level and `cd` into it. We'll use the usual convention of calling it `build` .

* The cmake build of Open62541 creates a static library by default. This type of library is needed for the EMBED type of Device Support build (see below).
Expand Down Expand Up @@ -135,7 +149,8 @@ See the [Windows Installation How-To][windows-howto] for an overview and introdu

Inside the `configure` subdirectory or one level above the TOP location, create a file `RELEASE.local` that sets `EPICS_BASE` to the absolute path of your EPICS installation.

Inside the `configure` subdirectory or one level above the TOP location, create a file `CONFIG_SITE.local` that sets the absolute path of your Open62541 installation as well as its build and deploy features if necessary.
If you have not used the install script,
inside the `configure` subdirectory or one level above the TOP location, create a file `CONFIG_SITE.local` that sets the absolute path of your Open62541 installation as well as its build and deploy features if necessary.
You also need to configure the locations of the other dependencies that you installed.

```Makefile
Expand Down
74 changes: 74 additions & 0 deletions devOpcuaSup/open62541/install_open62541.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
#
# This script installs the open62541 library for OPC UA support in EPICS.
# It downloads the specified version of open62541, builds it, and configures the EPICS environment.
# It requires curl, cmake and openssl-dev to be installed on the system.
#
# Usage: ./install_open62541.sh [version]
# If no version is specified, a default version is defined in the script.

# Default version of open62541 to use
DEFAULT_VERSION="1.3.15"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="$SCRIPT_DIR/temp_build"
LIB_DIR="$SCRIPT_DIR/lib-open62541"
OPEN62541_VERSION=${1:-$DEFAULT_VERSION}

# Check if cmake and curl are available
if ! command -v cmake &> /dev/null || ! command -v curl &> /dev/null; then
echo "Error: cmake and/or curl is not installed. Please install them and try again."
exit 1
fi

echo "Removing any existing build and library directory..."
rm -rf "$BUILD_DIR"
rm -rf "$LIB_DIR"

mkdir -p "$BUILD_DIR"
mkdir -p "$LIB_DIR"

# Download and extract open62541 if not already present
echo "Downloading open62541 version $OPEN62541_VERSION..."
curl -L "https://github.com/open62541/open62541/archive/refs/tags/v$OPEN62541_VERSION.tar.gz" \
| tar -xz -C "$BUILD_DIR" --strip-components=1
if [ $? -ne 0 ]; then
echo "Error: Failed to download and unpack."
exit 1
fi

echo "Building open62541..."
cmake \
-S "$BUILD_DIR" \
-B "$BUILD_DIR"/build \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX="$SCRIPT_DIR"/lib-open62541 \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF \
-DOPEN62541_VERSION="v$OPEN62541_VERSION" \
-DUA_ENABLE_ENCRYPTION=OPENSSL
if [ $? -ne 0 ]; then
echo "Error: cmake configuration failed."
exit 1
fi
make -C "$BUILD_DIR"/build
if [ $? -ne 0 ]; then
echo "Error: make failed."
exit 1
fi
make -C "$BUILD_DIR"/build install
if [ $? -ne 0 ]; then
echo "Error: make install failed."
exit 1
fi
rm -rf "$BUILD_DIR"

echo "Writing configuration to CONFIG_SITE.local..."
cat <<EOL > "$SCRIPT_DIR/../../configure/CONFIG_SITE.local"
OPEN62541 = \$(TOP)/devOpcuaSup/open62541/lib-open62541
OPEN62541_DEPLOY_MODE = EMBED
OPEN62541_USE_CRYPTO = YES
OPEN62541_USE_XMLPARSER = YES
USR_CXXFLAGS += -std=c++11
EOL

echo "open62541 version $OPEN62541_VERSION installed successfully. You should now be able to build the OPC UA support in EPICS."
Loading