Building Qt OPC UA with open62541

Qt OPC UA is not included in the Qt installer and must be built from source.
The open62541 backend is currently the most stable and feature complete open source backend in Qt OPC UA. The open62541 library has minimal external dependencies and can be built for all supported platforms (Linux, Windows (MinGW32, MSVC 2017), Android, macOS and iOS).

NEW: Starting with the 5.12 branch, Open62541 v0.3.0 has been added to Qt OPC UA  as a 3rd party source. The open62541 plugin is now built by default without requiring any additional setup.

Requirements

First of all, an installation of Qt 5.12 is required. Using the Qt installer also provides the necessary tools required to build Qt OPC UA except Perl which must be installed manually.

Building on Windows

MinGW32

Execute the following commands in the  “Qt 5.12.0 for Desktop (MinGW 5.3.0 32 bit)” shell

MSVC 2017

Execute the following commands in the “Qt 5.12.0 64-bit for Desktop (MSVC 2017)” shell

Building for Android

The Android NDK is required to build for Android.

Building on Windows

Execute the following commands in the  “Qt 5.12.0 for Desktop (MinGW 5.3.0 32 bit)” shell

Building for iOS

XCode is required to build for iOS.

Creating the documentation

Use the same shell and the platform specific make tool that has been used in building the Qt OPC UA module. Building the docs on Linux or macOS requires using sudo to execute the second step if Qt has been installed to a location not writable by the current user.

Building the examples

Use the same shell and the platform specific make tool that has been used in building the Qt OPC UA module. The examples will be created in “examples” in the build directory.

105 thoughts on “Building Qt OPC UA with open62541”

1. Xinghua Chen says:

can you add opuua server support

1. Frank Meerkoetter says:

We are actually thinking about a server side API, but so far nothing is planed for the short to mid-term range. We currently focus on completing the client side API.

Should we need to buy a commercial license for using Qt OPC UA in a closed source application ? The query is limited to Qt OPC UA( not the backend) and we are perfectly good with Open62541 which is under MPL.

Or are we good with dynamic linking (LGPL adherence) also for this module? This query happened since QtOPC UA is part of Qt Automation which needs commercial license.

1. Frank Meerkoetter says:

Unlike the rest of “Qt for Automation” which is dual licensed (commercial + GPL), Qt OPC UA is tripple licensed (commercial + LGPL + GPL).

Which means, as long as you can comply with the requirements of the LGPL (dynamic linking amongst others), you can use Qt OPC UA without a commercial license in a closed source application.

Dear Frank, Thanks for crystal clear reply.

3. lobi tocker says:

I have a Problem following the Instructions. It leaves me with: qopen62541backend.cpp:506:9: error: ‘UA_Client_runAsync’ was not declared in this scope

Any help would be useful
Best Regards

1. Frank Meerkoetter says:

are you sure you are building against the 0.3 branch of open62541?

1. lobi tocker says:

Or well, on my first try i had been on master and maybe there still is a conflict. I will try to remove any related files and try again.

1. Frank Meerkoetter says:

Please let me know how it goes 🙂

2. lobi tocker says:

Cleaning up and rebuilding on 0.3 fixed it… thanks

1. Frank Meerkoetter says:

You are welcome! As you might know Qt OPC UA is currently a tech preview. To stabilize the API we rely on user feedback (missing features, is the API good, use cases covered, …). Please let us know if Qt OPC UA works or what doesn’t work for you. We are also interested in the scenarios where the module is used.

4. lobi tocker says:

Yes. 100% sure

5. Javier says:

Great post!.

I have compiled Qt OPC UA and open62541 on Linux. However, when I check the number available backends with QOpcUaProvider I get 0.

Apparently, the Qt OPC UA compilation was fine.

Qt Opcua:
FreeOpcua ………………………… no
Open62541 ………………………… yes
Unified Automation C++ SDK …………. no

test config.qtopcua_opcua.libraries.open62541 succeeded

How do I have to include Qt OPC UA and open62541 in my pro file? I tried this two ways:

1.- Include OPC UA module

include(qt_plugin_open62541_backend.pri)
include(qt_lib_opcua.pri)
QT += opcua

2.- Directly link to the library

LIBS += -lQt5OpcUa

Any idea why I am getting zero backends providers in both cases? Thanks.

1. Jannis Voelker says:

After a successful installation of Qt OPC UA with the open62541 backend, the following file must be present:
/path/to/Qt/5.11.0/gcc_64/plugins/opcua/libopen62541_backend.so

Does this file exist in your installation?

To use Qt OPC UA in your project, the only additional entry required in the .pro file is “QT += opcua”.

1. Javier says:

Thank Jannis,

Yes, the file exists but in a local folder, I just copied it to the appropriate Qt5 plugin folder and now it is working.

1. Jannis Voelker says:

The file should have been copied automatically. Have you skipped the “make install” step after building the Qt OPC UA module?

6. Tobias Graspointner says:

When i want to compile the open62541 with MSVC 2017, i get the error U1095 every time while executing nmake. What can i do?

7. Hello there,
I am trying to build the library and I have stumbled upon a problem I cannot overcome. I have described it here in the forums: https://forum.qt.io/topic/92432/running-and-installing-opc-ua/4 Basically I am able to successfully build Open62541. After that I move to the opcua building phase. The problem is that after I run qmake, the script shows that Open62541 is not installed (like described in the forums). What could be the case in here? I would really appreciate all help.

1. Jannis Voelker says:

I can’t see an obvious error in the information you posted in the forum. Please add the content of the config.log file created by qmake to the thread, it will most likely help solving the problem.

8. Boris Skegin says:

Hallo,

do I see it right that QT OPCUA API does not cover yet the case

1. Jannis Voelker says:

I will extend the documentation accordingly.

1. Boris Skegin says:

Thansks a lot so far.

2. Boris Skegin says:

Server. See https://github.com/sirop/qtopcua_test/blob/userpass/examples/opcua/opcuaviewer/mainwindow.cpp#L184-L188 .

I also tried:
 QUrl myUrl; myUrl.setUrl(mServerUrl->text()); myUrl.setUserName("OpcUaClient"); myUrl.setPassword("Password2018"); mOpcUaClient->connectToEndpoint(myUrl); 
not being sure if the order of setting QUrl matters.

What have I done wrongß

Regards,
boris

9. Guillaume VDK says:

hello, I have a problem when I try to compile Qt OPCUA on windows with open62541.

I am following this tutorial (Building On Windows – Mingw32)

I cannot seem to specify the path to the header open62541.h and the lib open62541.a even if I did

set QTOPCUA_OPEN62541_INCLUDE_PATH=d:\open62541\build
set QTOPCUA_OPEN62541_LIB_PATH=d:\open62541\build\bin
Note that open62541 is compiled and that I do have the files open62541.h and libopen62541.a (in version 0.3) where they should be.

The error I get is a linker problem : cannot find -lopen62541

I added manually the open62541.h to the project files since it was not working either.

What should I do to specify correctly the path to open62541 please ? Is there an up-to-date documentation ?

1. Jannis Voelker says:

Which branch of the Qt OPC UA repository are you trying to build?
The steps in this tutorial are for the 5.11 branch, dev and 5.12 use a different way to configure the external dependencies.

1. Guillaume VDK says:

I checked, I am trying to build the 5.11 branch. Do you know if the configuration for the external dependencies changed ?

1. Jannis Voelker says:

This should work.
Please delete all files from your build directory, run the steps from the tutorial again and provide the content of the config.log file that has been created by qmake. Maybe this helps to determine what went wrong.

10. GuillaumeVDK says:

Do you know how to deploy correctly an application using QT OPCUA ?
Under Windows, with windeployqt, it adds the dll Qt5OpcUa.dll but it seems that there is no backend for the QOpcUaProvider class when running the program.
Do I also have to add the dll to open62541 ? (which is weird because it was linked statically ?)

1. Jannis Voelker says:

The application also needs the open62541 plugin.
windeployqt does not copy the plugins by default, they must be copied to /plugins/opcua/ manually.

1. Guillaume VDK says:

It works !
I want to sincerly thank you for your time and for this tutorial, I needed to use QT OPC UA for a project and succeded thanks to your help. Without it I would probably still be banging my head on my desk.
Again, Thank you 🙂

2. Gauquelin says:

Hello, After the windeployqt command, I add the open62541_backend.dll to the folder with my .exe. But I always have a crash when I try to connect to my server. Is there other file to copy from the mingw32 folder ?

11. Alex says:

On a fresh install of Ubuntu 18.04 with Qt 5.11.1 and have tried to build for Android following your process. (Do I need to build for Linux too?)

Everything seems okay when building but running a Qt application fails as no backends are detected.
provider.availableBackends().isEmpty()

I noticed another comment regarding the same issue and you said to check for a “libopen62541_backend.so”.
I’m able to find this file under ~/Qt/5.11.1/android_arm7/plugins/opcua

Would you have any ideas?

Any help would be greatly appreciated.
Many thanks

1. Jannis Voelker says:

The open62541 backend plugin is only built if the open62541 library is available.
Did you see the message “Open62541 ………………………… yes” after running qmake?
Please provide the config.log file created by qmake, it should state the reason why the plugin was not built.

12. Boris Skegin says:

Your install script works also with Microsoft Visual Studio 14.0 .

Only when doing nmake docs I get some problems: https://pastebin.com/R4H7jSaP .

Tested opcuaviewer with simulationsserver, everything works so far.

Thanks.

13. Berna says:

Hello,
I’m on a stuck with a problem and some help will be appreciated it.
I’ve installed open62541 following this tutorial (Building On Windows – Mingw32) and seems like everything are ok, but when I try to connect my own client with a demo opcua server the QOpcUaClient::ClientState(Connecting) is always connecting state (no matter if server is running or not).

Debugging I can see:

-qopen62541backend.cpp:
Open62541AsyncBackend::connectToEndpoint(const QUrl &url) is emitting signals correctly (connected when server is running or disconnected when not) so far I think it’s ok.

On other hand, qopcuaclientprivate.cpp:
void pcUaClientPrivate::setStateAndError(QOpcUaClient::ClientState state, QOpcUaClient::ClientError error) seems like should receive the signals from backend class but it doesn’t work, so client state still on connecting.

I also tried with other compiler (“Qt 5.11.1 64-bit for Desktop (MSVC 2017)”) and still happen the same.

Berna.

1. Jannis Voelker says:

Hello,
I am unable to reproduce this behavior with the 5.11 branch of Qt OPC UA on Qt 5.11.1 .

The following minimal example produces the right state transitions (connecting -> connected -> closing -> disconnected if the server is running, connecting -> disconnected if it is not):

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

QOpcUaProvider provider;
QOpcUaClient *client = provider.createClient(“open62541”);

QObject::connect(client, &QOpcUaClient::stateChanged, [client](QOpcUaClient::ClientState state) {
qDebug() << "New state:" <disconnectFromEndpoint();
if (state == QOpcUaClient::ClientState::Disconnected)
exit(EXIT_SUCCESS);
});

client->connectToEndpoint(QUrl(“opc.tcp://127.0.0.1:43344”));

return a.exec();
}

What result do you get when running my example?

14. Berna says:

Hello Jannis,

First at all, I want to say thanks you for your feedback.

Despite your example work perfectly, I’m afraid that I found some issue when I tried to work with my QThread class:
– QObject::connect(client, &QOpcUaClient::stateChanged, [client](QOpcUaClient::ClientState state): “client” have to be local not a class member, it doesn’t a big deal and I change it to a local QOpcUaClient but that bring me again to the same problem client->state() still on connecting.

In order to fix this I tried to install open65241 with option:

cmake -DCMAKE_BUILD_TYPE=Release -G “MinGW Makefiles” -DUA_ENABLE_AMALGAMATION=ON -DUA_ENABLE_MULTITHREADING=ON ..

Unfortulately it doesn’t work neither.

So what do I doing in a wrong way?

1. Jannis Voelker says:

Hello,

the Qt OPC UA open62541 backend is single threaded, Qt OPC UA also does not make any promises to be thread-safe.

15. Matteo says:

Hello, I am using Qt 5.5 and I tried to compile Qt OPC UA with this version. However during the compilation I got some errors from make. I think that these errors are due the fact that I am using Qt 5.5, but the recommended version is Qt 5.11 (I tried with Qt 5.11 and works fine). In this case, is it mandatory to use Qt 5.11 or with some minor changes is it possible to use Qt 5.5?

1. Jannis Voelker says:

Hello,
as Qt OPC UA is a new module which has been first released with Qt 5.11, backwards compatibility was not a goal during implementation.
The oldest Qt version I have built it for is 5.10.

Since Qt 5.5, there have been many changes to the Qt code base and to the build system. I can’t tell how extensive the changes to the Qt OPC UA code would need to be.

1. Frank Meerkoetter says:

As Qt 5.5 is a release that is still C++98, I have little hope. Porting would be a lot of work.

1. Matteo says:

Thanks for your answers, I actually saw that there are many differences. We are thinking of moving to Qt 11.

I’m not sure if it’s a problem with my configuration (most likely), but I had to add to “opcuaviewer.pro” file the path to the libraries with “QMAKE_RPATHDIR += /home//Qt/5.11.0/gcc_64/lib”, because I got errors like “:-1: warning: libicui18n.so.56, needed by /home//Qt/5.11.0/gcc_64/lib/libQt5Core.so, not found (try using -rpath or -rpath-link)”

16. AC says:

Many thanks for this guide and thework on the library, it’s really helped me with incorporating OPC-UA into an Android Application.

A few issues I’m unclear on though and I’m struggling to find much info, if you could help that would really be appreciated:

Is it at all possible to retrieve historical data for a historised node, e.g. get the values between some start time and an end time? My server application supports this but I can’t find an easy way to get at the data from the client.

Is there any further documentation or guidelines on calling method nodes?
Trying to call a method on my server from client I can see the call arriving server-side and the results being prepared but but 75% of the time I’ll receive a ‘BadConnectionClosed’ on my Qt Client and an empty result.

1. Frank Meerkoetter says:

We are happy if Qt OPC UA works for you!

About historical data access. This is something that is currently still missing from the API. It might be something for Qt 5.13. It won’t be in 5.12.

Some background: the underlying open62541 is (on 0.3) currently missing this functionality. Its available on their master, but not stable API wise (yet). So if their master settles down into an 0.4 beginning of 2019, it might be there for Qt 5.13.

2. Jannis Voelker says:

Hello,

Qt OPC UA does not yet support the HistoryRead service, but It’s on our to-do list.

The water pump example and the auto tests use method calls, but generally the server should just reject the call request if it does not like the arguments that were passed. What server application are you using? Does the same problem occur if you’re running the client application on a different platform (Windows, Linux…)?
Wireshark is able to dissect the OPC UA protocol. Does it show any indications on what went wrong?

1. AC says:

Thank you both for your replies.

The Water Pump example is one I had a look at to get started:
Does the NodeId of CallMethod need to be the same Id as the node you’re using to make the call?

E.g. Node1->CallMethod(, …) ?
Node2->CallMethod(, …)
My server is a Raspberry Pi using the Python FreeOpcUa library to implement the server. (https://github.com/FreeOpcUa/python-opcua)

The function is basically a very crude request for historical data (hence my earlier question!) that returns a string of timestamp/value pairs for a given node. It takes in strings at the moment just to test with sending parameters but these would eventually be datetimes.

On the Server:

lambda id=0, s=”start”, end=”end”, node=result: *default args* [ua.Variant((), ua.VariantType.String)], *Method*
[ua.VariantType.String, ua.VariantType.String], *In Args* [ua.VariantType.String]) *Out Arg*

On the Client:

node->callMethod(, args);

args is a QVector with two elements.

QPair(QString(“TestStart”),QOpcUa::Types::String)

I get no errors on the server side; I see a trace for the method being received, the parameters parsed and the data for the node retrieved and returned. However on the client this rarely comes through, more often than not I’ll see:

qt.opcua.plugins.open62541: Could not call method: BadConnectionClosed

qt.opcua.plugins.open62541: Unable to send publish request

I’ve tried using a completely different client (UaExpert) on Windows and connecting to my server and couldn’t recreate the issue – I’ll see if I can set my client application up on Windows or Linux and try again; will also look into Wireshark too.

Thanks again and apologies for such a long post.

1. Jannis Voelker says:

The output from the open62541 plugin indicates that the client closes the connection because it considers a messages received from the server as invalid. This could for example be caused by an unexpected sequence number. Wireshark will show the last message from the server before the connection is closed, the best bet is to check the headers of this message and the previous one for any strange values.
You could also build open62541 with a more verbose log level and see if you get any output which indicates what went wrong.

17. simon says:

Hi Frank:
I am stuck in mingw32 make (building qt opc ua)
here is the message:
‘perl’ is not recognized as an internal or external command,
operable program or batch file.
Project ERROR: Failed to run: perl -w C:\Qt\5.11.1\mingw53_32\bin\syncqt.pl -mod
ule QtOpcUa -version 5.11.2 -outdir C:/Qt/5.11.1/mingw53_32/open62541/qtopcua/bu
ild -builddir C:/Qt/5.11.1/mingw53_32/open62541/qtopcua/build C:/Qt/5.11.1/mingw
53_32/open62541/qtopcua
Makefile:41: recipe for target ‘sub-opcua-make_first’ failed
mingw32-make[1]: *** [sub-opcua-make_first] Error 3
mingw32-make[1]: Leaving directory ‘C:/Qt/5.11.1/mingw53_32/open62541/qtopcua/bu
ild/src’
Makefile:42: recipe for target ‘sub-src-make_first’ failed
mingw32-make: *** [sub-src-make_first] Error 2

How can I overcome this?

1. simon says:

I manged to install it.

2. simon says:

Never mind. I managed to solved it. The code I copied from
https://blog.basyskom.com/2018/want-to-give-qt-opcua-a-try/
failed at “No backends found”.

{
QOpcUaProvider p;
qDebug() << "Available backends:" << p.availableBackends();

if (p.availableBackends().size() == 0) {
qDebug() << "No backends found";
return false;
}

m_client.reset(p.createClient(p.availableBackends()[0]));

if (!m_client) {
qDebug() <connectToEndpoint(QUrl(“opc.tcp://opcua.demo-this.com:51210/UA/SampleServer”));
return true;
}

3. simon says:

Never mind. I managed to install it. but I am unable to run the simplest code.

QOpcUaProvider provider;
QStringList available = provider.availableBackends();
if (!available.isEmpty()) {
QOpcUaClient *client = provider.createClient(available[0]);
if (client)
qDebug() << "Client successfully created";
}
The Backend is empty. I am using Kepware OPC UA as server
When I tried you code, the same thing No Backend availabe.
What is backend?

18. simon ong says:

Hi:
I left a message few hours ago. apparently after reading the post earlier on, I realized at the qmake .. process the message
Open62541 ………………………… no—> which meant the qmake failed?
my question:

1) Build open62541 and Build Qt OPC UA are both in different directory?

2) how can i overcome qmake failure?

3) where is open62541 plugin after build ?

Thanks

1. Jannis Voelker says:

Hello,
if “Open62541” is marked as “no”, this means that qmake was unable to find or use the open62541 library when running the config tests.
Did you follow the steps for MinGW in “Build open62541”?
If you are not sure, please do so, then erase all files from the Qt OPC UA build directory and repeat the steps listed in “Build Qt OPC UA”.
If it still does not work, check the config.log file created by qmake. It should show the reason why the config tests failed to find or use the open62541 library.

After a successful build, the plugin will be available in the plugins/opcua directory.

1. simon ong says:

Hi Jannis:
My bad. I found the mistake that I made. Well , I am start exploring it right now. I had written code (C#) as a client to opcserver. The step of connecting is quite straight forward.

Can you point me to simple client code that connect to OPC server, and read a value or a array of addresses?

I am able to connect to the current opc server reside in my laptop, but still figuring out how to read some addresses from the server

19. simon ong says:

Hi:
Missing signal in QOpcUaNode?
‘dataChangeOccurred’ is not a member of ‘QOpcUaNode’
QObject::connect(m_node.data(),&QOpcUaNode::dataChangeOccurred,this, &MainWindow::UpdateValue);

1. Jannis Voelker says:

Hello,
this signal has been added in the 5.12 branch which is currently under development.
I guess you have found the preview version of the documentation.
The docs for Qt OPC UA 5.11 are available here: https://doc.qt.io/QtOPCUA/qtopcua-index.html

The Qt OPC UA examples are a good starting point. The water pump example shows how to use read, write, monitoring and method calls, the explorer example shows the browse API.
The browser example

1. simon ong says:

Hi:
Thank you for the information.

Regards

20. track says:

I seem to have an issue with my connections dropping after around ~10 minutes.

I’m only connecting to servers and monitoring a single variable for change and then potentially requesting some additional values depending on its result – nothing taxing

Is this something you’ve seen before? Or would you have any recommendations on how best to find the cause of this.

My server is a Raspberry Pi running a Python Free-OPCUA Server and the Qt client is running on an Android device.

Many thanks

21. AC says:

I’m having some trouble with subscribing/monitoring nodes – the connection to the server will drop out after roughly 10 minutes every time.

I’ve tried other clients (UAExpert / Prosys) and they don’t seem to drop connection, so I’m wondering what I’ve done wrong.

Basically I have an application that subscribes to a node common to my OPC servers I then wait for it to change value and react accordingly (it looks a bit like this):

QOpcUaNode* n = devices[deviceName]->client->node(“ns=2;s=Common-Node”);

n->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(500));

connect(n, &QOpcUaNode::attributeUpdated,
this, [this,deviceName](QOpcUa::NodeAttribute attr, QVariant value)
{
if(value.toBool()){
qDebug() << "Update received on NVF for: " << deviceName;
}
});

Checking the output I see an entry for "Open62541: Unable to Send Publish Request" (I've tried rebuilding the library with a higher log level but there's no difference) I can't seem to find any further details.

I'm not really seeing anything on Wireshark either the packets just seem to stop.

Would you be able to advise?

Many thanks

1. Jannis Voelker says:

Hello,
10 minutes sounds like a typical interval for renewing the secure channel. Can you confirm with wireshark that this is what happens just before the connection is closed?
Related issue in the open62541 bug tracker: https://github.com/open62541/open62541/issues/2092

1. AC says:

Hi Jannis,

Sorry for the double post, the related issue is my own actually (good find).

Trying again today and it seems that any interaction with the server after ~10 minutes causes the connection to drop, so its probably not a specific subscription issue.

There are some security policies to choose from on FreeOpcUa, is there a type expected by QtOpcUa / Open62541 or a way to specify?

I’ll run it again and check the Wireshark output at the disconnect point, is there any specific I should look for? (not something I’m too familiar with)

Thanks again

2. Hackbeere says:

How to renew a secure channel with Qt OPC UA?

1. Jannis Voelker says:

There is no API to do this in Qt OPC UA, renewing the secure channel is considered a detail that must be handled internally by the sdk specific plugins (open62541, unified automation).

Did you encounter any problems with secure channel renewal with one of the plugins?

1. Hackbeere says:

For automatic “secure channel renewal” you need at least one subscription to a value (ex. server status time).

If the application only read or write value attributes the OPC UA server will disconnect after RevisedLifetime (in OpenSecureChannelResponse message). In my case after 12 Min. with a Siemens PLC.

2. Jannis Voelker says:

Which branch of Qt OPC UA are you using?

22. WangYun says:

Hey Frank,
I’ve done install the opcua libray. when i build the example(***\qt\5.11.2\mingw53_32\open62541\build\qtopcua),
i get these errors.:
“Project ERROR: You cannot build examples inside the Qt source tree, except as part of a proper Qt build.
Makefile:33: recipe for target ‘sub-opcua-qmake_all’ failed
mingw32-make: *** [sub-opcua-qmake_all] Error 3”
I’m not familar with QT, hoping to get your help. thanks

1. Jannis Voelker says:

Hello,
according to the path, your build directory is located inside the Qt installation directory.
As the error message states, this is not permitted when building examples.
When building additional Qt modules for an existing Qt installation, the usual approach is to build them in a directory outside of the Qt installation directory. The files required to use the new module are copied to the Qt installation directory using “make install”. With such a setup, the examples can be built in the build directory that was used for the module itself.

23. Boris says:

Hello,
First of all thanks for these guidelines. They are quite helpful.
I have followed the indicated steps to set up Qt OPC UA on linux (debian) using Qt 5.11.2.
Everything seems to work fine, and the qmake configuration says that the open62541 plugin has been installed successfully.

The problem I am facing occurs when attempting to create a client.
Here is the error I get:
<>

So though the open62541 plugin available and found, it is failing to load. What could be the cause of this behavior?

1. Jannis Voelker says:

Hello,
Wordpress seems to have removed the error message from your comment.
There are two things you could check:
1) Run the command line ldd /path/to/Qt/5.11.2/gcc_64/plugins/opcua/libopen62541_backend.so and make sure libopen62541.so points to your open62541 installation.
2) Run your Qt OPC UA application with the environment variable QT_DEBUG_PLUGINS set to 1 and see if there is any output related to the open62541 plugin.

1. Boris says:

In fact, when I run the command lld /path/to/Qt/5.11.1/gcc_64/plugins/opcua/libopen62541_backend.so, libopen62541.so does not point to the open62541 installation.
What can then be the reason of this? And how can it be fixed?

1. Jannis Voelker says:

This looks like your open62541 installation has somehow failed or you have installed it to a path that is not automatically searched for libraries.

2. Boris says:

I have followed this tutorial: “http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html” , and I was able to fix the path to which libopen62541.so should point to by adding in /etc/ld.so.conf.d/ a ‘.conf’ file with the path to the actual path open62541 installation.

24. Larry says:

I am trying to build qtopcua 5.12 against OPEN62541 0.3 without success. 5.11 works well, but I was hoping to use features such as findServers and requestEndpoints without digging into OPEN62541. Is this configuration currently possible? Is it on a roadmap? There doesn’t even seem to be an existence test for OPEN62541 in qtopcua\src\opcua\configure.pri. (WIN 7 and 10)

1. Jannis Voelker says:

The way to specify build parameters for Qt OPC UA has changed between Qt 5.11 and Qt 5.12.
I have just updated this howto to show the steps necessary for building the 5.12 branch of Qt OPC UA with Qt 5.12.0.
Please let us know if you have further problems with building and using Qt OPC UA.

1. Larry says:

Thank you for that. 5.12 now builds successfully on msvc. I’ll let you know how well discovery services work.

25. Bence says:

Hi! Did the way to specify build parameters on linux also change? I tried to build 5.12 with OPEN62541 on linux the same way as 5.11.3, but qmake did not detect OPEN6254.

1. Jannis Voelker says:

When building for Qt 5.12, it is important not to forget the step “git checkout 644761ff” when building open62541.
After this commit, the install path for the open62541 header file is changed and the config test fails to detect the open62541 library.

1. Bence says:

Thanks, I will try recompiling open62541 first then.

26. Larry says:

I am trying to build qtopcua using the new build scheme with open62541 as 3rd party source. I am trying to include mbedtls, to take a swipe at authentication/encryption.

All goes well until the link step, when it complains about not finding members of the mbedtls libraries. (first one is mbedtls_md_info_from_type) Can you give me a hint as to how to link them in the qtopcua build system? The open62541 instructions no longer seem to apply.

1. Jannis Voelker says:

You could try adding the following line in src/3rdparty/open62541.pri: LIBS += -lmbedtls -lmbedx509 -lmbedcrypto

An API for secure connections has been added on the Qt OPC UA dev branch which is going to become Qt 5.13 soon. The open62541 plugin does not support that API yet because we are tied to open62541 v0.3.0 which does not offer client side secure connection capabilities. The uacpp plugin code already has an implementation for this and can be used as an example for how to implement the secure connection API.

1. I am thinking that I have not built the mbedtls libraries appropriately. (using qtcreator) cmake appears to find the libraries, but can’t resolve their members. DUMPBIN shows the members with a preceding underscore, which shouldn’t be an issue.

I will explore compiling mbedtls again. The instructions (I am working on windows 7 with vs2017) fail to generate mbedcrypto and mbedx509, and I had to create the project files manually.

I am using open62541 [master] and qtopcua [5.13]. qtopcua compiles (except for the link phase) with a change only to qopen62541subscription.cpp to work around deprecated code that has been removed in open62541 [master].

Since the bleeding edge version of open62541 appears to support client side encryption/authentication (there is example code in the tree) I thought I would try to put a qt wrapper around it and and see if it works. We require authentication and encryption.

2. Frank Meerkoetter says:

In addition to what Jannis said. We might not be able to get open62541 client security into Qt OPC UA proper (aka. a released version) before open62541 has settled down into an 0.4 branch (or a release candidate at least), but we see the need for having this feature. One way could be to have a “known to work” patch in gerrit (open62541 users need to build from source anyways). We are happy to collaborate on that.

27. Constantin Belyaev says:

Thank you for great work!

Is there any roadmap for Qt OPC UA features and dates?

28. I still haven’t given up on adding security to qtopcua; I got sidetracked just after I figured out how to set up a security infrastructure and compiled against mbedtls. Still gonna do it.
I am stuck trying to deploy an app. Plain vanilla Qt opcua, built in qt creator. It simply accesses the library, gets a list of endpoints, then creates a new QOpcUaProvider, and attempts to load a backend, connect a server, then update the server periodically from a Reflective memory network.
It works perfectly in qcreator, either run or debug, but as a standalone (accompanied by dependencies provided by windeployqt.exe) the provider does not report any backends. (verified with printf) I put a delay (x1000 sqrt(f) so it doesn’t kill the thread) in, but doesn’t appear to be a timing issue. Is there or are there some dependency(ies) that windeployqt.exe might be missing that qtcreator provides in it’s configuration? Could it be a visual studio issue? ( it seems to work on a VS2017 system if I build it there, but not when compiled against VS2015) Unfortunately my target platform is 2015, and cannot have a qt install or 2017.

The dev machine has qtopcua built with VS2015

I have a couple of servers built the same way (based loosely on the waterpump example) that stand up and run just fine.
Any suggestions you can provide would be most appreciated.

1. Frank Meerkoetter says:

I guess windeployqt doesn’t copy the plugins (the open62541-backend is a plugin). Please check the target folder of the deployment if you find the backend there.

btw. Christmas comes early this year: https://codereview.qt-project.org/#/c/256710/
This patch is a “fork” which implements the security API with open62541 based on their master. We currently can’t merge it as we need a proper release of open62541, but its still something you can already check out and test. We are looking forward to your feedback.

29. Larry says:

Sorry for the delay getting back to you. After reading the docs at
https://github.com/probonopd/linuxdeployqt a light bulb went off, and I manually included the plugin into the windeployqt bundle and things work as they should.
I guess now I should figure out how to apply a patch so I can check out the security preview, but right now I am having an issue porting an app from windows to linux (centos). Discovery works OK, but my client connect times out.

30. Thibault says:

Hello,

I have troubles when building the sources on Windows with MinGW32.
I installed Qt 5.13.0, Perl 5.3.1 and MinGW32 7.3.

When building sources with mingw32-make, I get an Invalid argument error. With details : [Makefile:45: sub-opcua-make_first] Error 126.

It may be related to an installation issue but I can’t see which one in particular.

1. Jannis Voelker says:

Hello,

is this the entire output, or is there more that could indicate what went wrong?
Are you able to call perl from the shell you are using to build Qt OPC UA without specifying the full path to the executable?

31. Ailen says:

Hello Frank，
I want use freeopcua, I read this blog for reference.
Firstly, I use “vckpg install freeopcua” to get freeopcua lib and dll.
Then,I use “Qt 5.11.0 32-bit for Desktop (MSVC 2015) “to compile Qtua plugin.The cmd like that “cd qtopcua
mkdir build
cd build
set INCLUDE=%INCLUDE%;C:\vcpkg-master\installed\x86-windows\include
set LIB=%LIB%;C:\vcpkg-master\installed\x86-windows\lib
qmake ..
nmake
nmake install”
I get the plugin successly .At last , I try the plugin,
—– QOpcUaClient *m_pOpcUaClient = m_pOpcUaProvider->createClient(lstBackends.first())
the m_pOpcUaClient is null, and the log is
qt.opcua: Failed to load OPC UA plugin: “freeopcua”
qt.opcua: Available plugins: (“freeopcua”).
What should i do with this error?

1. Frank Meerkoetter says:

Thank you for your interest. Please avoid using the freeopcua backend. It was our initial backend end has been removed with Qt5.12. Please consider switching to a recent version of Qt OPC UA and the open62541-backend. Note that recent versions of Qt OPC UA bundle open62541 so it is much easier to install. Also note that the open62541-backend has much more features then the freeopcua backend ever had.

32. Ailen says:

Thank for your reply .Actually I cannot get any endpoints from the OPC UA server with the lastest open62541 backend.The endpointArraySize in The function “static UA_StatusCode getEndpoints(UA_Client *client) ” is 0.
But the freeopcua can get endpoints and nodes from the same UA server .So i had to use freeopcua in my code if i cannot solve the problem on open62541

33. Ailen says:

Besides i have solved this problem. Because i forgot set boost environment variable.Setting BOOST_ROOT on environment variable can make qt load plugin successfully .
I still have doubts on this which open62541 cannot find endpoints in UA server

34. Pengfei Liu says:

Hello, thanks for so much information. Now I can run Qt opcua on Ubuntu desktop(both programing and execution on same PC with Ubuntu).
But I want to run this code on embedded Linux what should I do? It there some special settings? Or only should I recompile source code under cross compilation environment？

35. jaarfi says:

Hello,

I am having trouble getting it to work correctly. I followed your steps ,QtopcUa build correctly and a project including it compiles. Despite this i have no avaiable backends, even though in my qmake step it recognized it.

1. jaarfi says:

in the qmake step it recognized open62451*

36. Henrik says:

Hello,
I’m trying to run my application on a virtual machine, but open62541 can’t find any backends. It works in Qt on my computer and as a standalone app. However, if I copy my app and all DLLs to the virtual machines, my app cannot find any backends. For OPC UA I copied open62541_backend.dll, Qt5OpcUa.dll and declarative_opcua.dll.

1. Jannis Voelker says:

Hello,
did you just copy all DLLs to the same directory? Qt looks for plugins in certain places, the open62541 plugin should be recognized if you place it inside plugins/opcua/.

1. Henrik says:

Hello Jannis,
I used windeployqt for my standalone app, but I had to copy the files open62541_backend.dll and declarative_opcua.dll.

2. Henrik says:

Now I installed Qt and the QtOPCUA Plugin on the virtual machine and finally it works! Any ideas for the reason?

37. marco says:

Hi
I tried to build the QtOPCUA but failed.
After installing ActivePerl on Windows10 I run qmake and then nmake but I have the following error:

Unable to open: ../openssl/asn1.h
Any idea?
Thanks

1. Frank Meerkoetter says:

This seems to be unrelated to Qt OPC UA? Can you provide a bit more context please? Which backend are you trying to build?