Building Qt OPC UA with open62541

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


First of all, an installation of Qt 5.11 is required. Using the Qt installer also provides the necessary tools required to build Qt OPC UA.
Building open62541 requires CMake and Python. The Python package six must be installed from a terminal before starting the build by executing

Building the Qt OPC UA module requires an installation of Perl.

Building on Linux

Build open62541

Build Qt OPC UA

Building on Windows


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

Build open62541

Build Qt OPC UA

MSVC 2017

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

Build open62541

Build Qt OPC UA

Building for Android

Additional requirements

An Android NDK and CMake >= 3.6.0 are required to build for Android.

Building on Linux

Build open62541

Build Qt OPC UA

Building on Windows

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

Build open62541

Build Qt OPC UA

Building for iOS

Additional requirements

XCode is required to build for iOS

Build open62541

Build Qt OPC UA

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 OS X 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.


62 thoughts on “Building Qt OPC UA with open62541”

    1. 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.

  1. 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. 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.

  2. 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. 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. 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.

  3. 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

    QT += opcua

    2.- Directly link to the library

    LIBS += -lQt5OpcUa

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

    1. After a successful installation of Qt OPC UA with the open62541 backend, the following file must be present:

      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. 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. The file should have been copied automatically. Have you skipped the “make install” step after building the Qt OPC UA module?

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

  5. 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: 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. 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.

  6. Hallo,

    do I see it right that QT OPCUA API does not cover yet the case
    of server connection with username and password whereas open62541 0.3 does cover such a case already?

    1. Connecting to a server with username and password is supported for servers which don’t require an encrypted password. Username and password must be passed as part of the QUrl in connectToEndpoint() (opc.tcp://user:pass@host). This can be done directly or by using url.setUserName(“user”) and url.setPassword(“password”).

      I will extend the documentation accordingly.

      1. Hallo, just tried your advice with Siemens Sinumerik OPC UA 2.0
        Server. See .

        I also tried:

        QUrl myUrl;

        not being sure if the order of setting QUrl matters.
        Result: .

        However, when my using UA Expert both username and password were accepted. Pic: .

        What have I done wrongß


  7. 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. 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. I checked, I am trying to build the 5.11 branch. Do you know if the configuration for the external dependencies changed ?

        1. 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.

  8. 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. The application also needs the open62541 plugin.
      windeployqt does not copy the plugins by default, they must be copied to /plugins/opcua/ manually.

      1. 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 🙂

  9. 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.

    I noticed another comment regarding the same issue and you said to check for a “”.
    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. 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.

  10. 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:

    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.

    I’m looking forward for your feedback. Thanks in advance.

    1. 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)


      return a.exec();

      What result do you get when running my example?

  11. 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:


    Unfortulately it doesn’t work neither.

    So what do I doing in a wrong way?

    Thanks in advance.

    1. Hello,

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

      Can you paste or upload your code somewhere?

  12. 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?

    Thank you in advance

    1. 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. 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 “” file the path to the libraries with “QMAKE_RPATHDIR += /home//Qt/5.11.0/gcc_64/lib”, because I got errors like “:-1: warning:, needed by /home//Qt/5.11.0/gcc_64/lib/, not found (try using -rpath or -rpath-link)”

  13. 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. 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. 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. 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. (

        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:

        add_method(, ,
        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.


        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. 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.

  14. 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\ -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
    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
    Makefile:42: recipe for target ‘sub-src-make_first’ failed
    mingw32-make: *** [sub-src-make_first] Error 2

    How can I overcome this?

    1. Never mind. I managed to solved it. The code I copied from
      failed at “No backends found”.

      bool QOpcUaReader::init()
      QOpcUaProvider p;
      qDebug() << "Available backends:" << p.availableBackends();

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


      if (!m_client) {
      qDebug() <connectToEndpoint(QUrl(“opc.tcp://”));
      return true;

    2. 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?

  15. 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 ?


    1. 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. 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

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

    1. 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:

      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

  17. 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

  18. 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)
    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. 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

Leave a Reply

Your email address will not be published. Required fields are marked *