basysKom AnwendungsEntwicklung

Building Qt OPC UA with open62541
Essential Summary
Qt OPC UA is not included in the Qt installer and must be built from source. The official default backend is based on the open62541 library which has minimal external dependencies and can be built for all supported platforms (Linux, Windows (MinGW32, MSVC 2017), Android, macOS and iOS).

Qt OPC UA is not included in the Qt installer and must be built from source.
The following article shows how to build the module with the open62541 plugin for Qt 6 and Qt 5.15.

Qt 6

While qmake is still available for Qt 6 based projects, all official Qt modules were ported to the CMake build system and the qmake .pro files were removed from their respective repositories.

Requirements

First of all, an installation of Qt 6 (we recommend the newest release or the latest LTS) is required. Using the Qt installer also provides the necessary tools required to build Qt OPC UA.

The open62541 versions used in Qt OPC UA for Qt 6 support OpenSSL, so the additional requirement for mbedTLS was dropped. The OpenSSL 3.x libraries and headers are necessary if security, GDS and X.509 support is required.

Compiling on Linux

git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 6.6.3
mkdir build && cd build
~/Qt/6.6.3/gcc_64/bin/qt-cmake ..
make
sudo make install # sudo is not required if Qt 6.6.3 has been installed to a directory owned by the user

Compiling  on macOS

git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 6.6.3
mkdir build && cd build
~/Qt/6.6.3/clang_64/bin/qt-cmake ..
make
sudo make install # sudo is not required if Qt 6.6.3 has been installed to a directory owned by the user

Compiling on Windows

MinGW64

Execute the following commands in the  „Qt 6.6.3 (MinGW 11.2.0 64-bit)“ shell

git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 6.6.3
mkdir build
cd build
qt-cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=c:\Qt\6.6.3\mingw_64 ..
mingw32-make
mingw32-make install

 

MSVC 2019/2022

Execute the following commands in the „Qt 6.6.3 (MSVC 2019 64-bit)“ shell

"c:\path\to\vcvarsx86_amd64.bat" # Source the vcvars belonging to the MSVC version installed on your system
git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 6.6.3
mkdir build
cd build
qt-cmake -G "NMake Makefiles" ..
nmake
nmake install

Documentation and examples

To build the official Qt OPC UA examples, the qt-cmake call must be extended with -DQT_BUILD_EXAMPLES=ON.

The documentation is built via <make/mingw32-make/nmake> docs.

Qt 5.15
The Qt OPC UA module for Qt 5.15 still uses the qmake build system.

Requirements

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

The security features of the open62541 plugin require the mbedTLS library and headers to be detected by qmake in order to be enabled. The GDS and X.509 support for the generic part needs the OpenSSL 1.1 headers and libraries to be available.

Compiling on Linux

git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 5.15.2
mkdir build && cd build
~/Qt/5.15.2/gcc_64/bin/qmake ..
make
sudo make install # sudo is not required if Qt 5.15 has been installed to a directory owned by the user

Compiling  on macOS

git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 5.15.2
mkdir build && cd build
~/Qt/5.15.2/clang_64/bin/qmake ..
make
sudo make install # sudo is not required if Qt 5.15.2 has been installed to a directory owned by the user

Compiling on Windows

MinGW32

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

git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 5.15.2
mkdir build
cd build
qmake ..
mingw32-make
mingw32-make install

MSVC 2017

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

"c:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\VC\Auxiliary\Build\vcvarsx86_amd64.bat"
git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 5.15.2
mkdir build
cd build
qmake ..
nmake
nmake install

Compiling for Android

Additional requirements

The Android NDK is required to build for Android.

Compiling on Linux

git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 5.15.2
mkdir build && cd build
export ANDROID_NDK_ROOT=/path/to/android-ndk-r17b
~/Qt/5.15.2/android_armv7/bin/qmake ..
# When building for android_x86 (e. g. simulator), use "~/Qt/5.15.2/android_x86/bin/qmake" instead
make
sudo make install# sudo is not required if Qt 5.15.2 has been installed to a directory owned by the user

Compiling on Windows

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

git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 5.15.2
mkdir build
cd build
set ANDROID_NDK_ROOT=c:\path\to\android-ndk-r17b
set ANDROID_NDK_HOST=windows-x86_64 # Only set this if the windows-x86_64 Android NDK is used
c:\Qt\5.12.0\android_armv7\bin\qmake ..
# When building for android_x86 (e. g. simulator), use "c:\Qt\5.15.2\android_x86\bin\qmake" instead
mingw32-make
mingw32-make install

Compiling for iOS

Additional requirements

XCode is required to build for iOS.

Compiling on macOS

git clone https://code.qt.io/qt/qtopcua.git
cd qtopcua
git checkout 5.15.2
mkdir build
cd build
~/Qt/5.15.2/ios/bin/qmake ..
make
sudo make install # sudo is not required if Qt 5.15.2 has been installed to a directory owned by the user

 

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.
 
make docs
make install_docs

 

Compiling 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.
 
export LD_LIBRARY_PATH=/path/to/Qt/5.15.2/gcc_64/lib/:$LD_LIBRARY_PATH # Linux only
make sub-examples
Frank Meerkötter

Frank Meerkötter

Frank Meerkoetter is the Development Lead for basysKom GmbH, where he is consulting customers on industrial and embedded applications, often in combination with Qt. He is responsible for the technical consulting, system- and software-architecture within basysKom. He is the maintainer of Qt OPC UA and a contributor to the Qt project. He has a strong background in Embedded Linux, systems programming, distributed systems and application development. He holds a Master of Computer Science from the University of Applied Sciences in Darmstadt.

181 Antworten

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

    • Whether QT webassembly suite can compile open62541 seems to use WS2 of windows_ 32 dynamic library, resulting in compilation failure

  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.

    • 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

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

        • 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

    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.

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

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

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

    • 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?

  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 ?

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

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

        • 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 ?)

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

      • 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 🙂

      • 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 ?

        • Hi Gauquelin,
          I came up with the same issue like you. I put the open62541_backend.dll to the release.exe folder, but the application still crash when trying to search the server.
          Finally, I find out the „open62541_backend.dll“ should be placed in the folder named „opcua“. And this „opcua“ folder push together with your .exe file. Then it works! You can try this way. Hopefully it also works on 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.
    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

    • 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:

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

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

    • 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?

  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:
    UA_ENABLE_MULTITHREADING ->ON

    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?

    Thanks in advance.

    • 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

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

        • 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)“

  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.

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

    • 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?

      • 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:

        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.

        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.

        • 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\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?

    • Never mind. I managed to solved it. The code I copied from
      https://www.basyskom.de/2018/want-to-give-qt-opcua-a-try/
      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;
      }

      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;
      }

    • 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 ?

    Thanks

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

      • 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(m_node.data(),&QOpcUaNode::dataChangeOccurred,this, &MainWindow::UpdateValue);

    • 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

  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

    • Hi! I have the same problem here with Android.
      Running the app in windows everything is fine, but when I try on Android all updates just stop, no signals emitted for client state or node.
      Have you find a solution?

  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)
    {
    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

      • 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

        • 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?

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

    • I’ve got almost the exact same problem, which is simply enable monitoring and then „Disconnected“ + „Unable to Send Publish Request“ appears. But the issue of mine is happened just after the first time of „DataChangeOccured“ that callback function is called, which is the „PublishInterval“ as 500 ms.
      UaExpert and Matrikon Explorer both work perfectly with the same server.

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

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

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

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

      • 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.
        Here how it looks like: “ libopen62541.so.0 => not found „.
        What can then be the reason of this? And how can it be fixed?

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

      • 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.
        Thanks though for your availability to address my doubt!

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

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

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

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

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

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

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

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

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

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

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

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

    Thank you for your help.

    • 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?

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

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

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

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

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

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

    Thank you for your help

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

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

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

  33. Hello Jannis/Frank,

    By following the steps on Compiling on Windows, I’m able to compile/build and install Qt Opc UA on Windows with MSVC compiler, I’m also able to compile/build using Mingw32-Make as well, but the error comes when I use mingw32-make install, some error messages happening as attached:

    mingw32-make[2]: Entering directory 'C:/Qt/5.14.1/mingw73_32/qtopcua/build/src/opcua'
    copy /y ..\..\lib\Qt5OpcUa.dll C:\Qt\5.14.1\mingw73_32\bin\Qt5OpcUa.dll
    1 file(s) copied.
    C:\Qt\5.14.1\mingw73_32\bin\qmake.exe -install sed -e "s,C:/Qt/5.14.1/mingw73_32/qtopcua/build/lib,$$[QT_INSTALL_LIBS],g" -e "s,C:\\\\Qt\\\\5.14.1\\\\mingw73_32\\\\qtopcua\\\\build\\\\lib,$$[QT_INSTALL_LIBS],gi" -e "s,C:/Qt/5.14.1/mingw73_32/lib,$$[QT_INSTALL_LIBS],g" -e "s,C:\\\\Qt\\\\5.14.1\\\\mingw73_32\\\\lib,$$[QT_INSTALL_LIBS],gi" ..\..\lib\Qt5OpcUa.prl > C:\Qt\5.14.1\mingw73_32\lib\Qt5OpcUa.prl
    C:\Qt\5.14.1\mingw73_32\bin\qmake.exe -install sed -e "s,C:/Qt/5.14.1/mingw73_32/qtopcua/build/lib,C:/Qt/5.14.1/mingw73_32/lib,g" -e "s,C:\\\\Qt\\\\5.14.1\\\\mingw73_32\\\\qtopcua\\\\build\\\\lib,C:\\\\Qt\\\\5.14.1\\\\mingw73_32\\\\lib,gi" ..\..\build\lib\pkgconfig\Qt5OpcUa.pc > C:\Qt\5.14.1\mingw73_32\lib\pkgconfig\Qt5OpcUa.pc
    ..\..\build\lib\pkgconfig\Qt5OpcUa.pc: No such file or directory
    mingw32-make[2]: *** [Makefile:3431: install_target] Error 1
    mingw32-make[2]: Leaving directory 'C:/Qt/5.14.1/mingw73_32/qtopcua/build/src/opcua'
    mingw32-make[1]: *** [Makefile:64: sub-opcua-install_subtargets] Error 2
    mingw32-make[1]: Leaving directory 'C:/Qt/5.14.1/mingw73_32/qtopcua/build/src'
    mingw32-make: *** [Makefile:65: sub-src-install_subtargets] Error 2

    Is there anything I missed?

  34. Hallo,
    ich habe gerade einen Server bei dem in einigen Nodes Umlaute im BrowseName(n) enthalten sind. Wird für diese Nodes ein QOpcUaNode::readAttributes ausgelöst, dann sind beim Eintreffen des Signals OpcUaNode::attributeReadFinished alle Attribute des Nodes ungültig.
    Dies kann man auch mit dem opcuaviewer-Sample nachvollziehen. Dort steht dann als BrowseName kein Name drin, die NodeClass ist Undefined usw…
    Was kann ich dagegen tun?

  35. Hello,

    I am a beginner of Qt. My system is Windows 10 64bit with Qt: 5.14.0
    I followed the process mentioned above. When I run „mingw32-make“, it pops out the fatel error: openssl/asn1.h: No such file or directory #include
    I searched a lot of solution to try to fix it. But still cannot solve it. I think some of users have same issue like I have. But the information is few.
    When I have almost ran out of ideas, I uninstalled the Qt: 5.14.0, and install the Qt: 5.12.0. And I do the exactly the same procedures like I did with Qt: 5.14.0. Eventually, succeeded!
    I don’t know why. But now is good for me. So I just share some information and see if you have any idea of what happened to me.
    Thanks in advance.

    • Hello,

      the 5.14 branch of Qt OPC UA has been extended with GDS support which requires OpenSSL 1.1 headers and libs to build.
      If this is not available, the build will fail.

      • I searched some information about qt 5.14 branch. There is an OpenSSL issue in this qt version. The installer doesn’t set up OpenSSL environment. So how can I build the OpenSLL 1.1 into the qt 5.14 branch manually. It is awesome if you can explain more detail about the process. As you know I am a beginner. But I will still try my best to fix it as well.

        • Just like when building Qt itself, you need to pass the location of the OpenSSL headers and libraries manually.
          Assuming you have installed OpenSSL to /path/to/openssl/, you can specifiy the locations as follows when running qmake:
          qmake /path/to/qtopcua -- QMAKE_CXXFLAGS="-I /path/to/openssl/include -L /path/to/openssl/lib"

  36. Hello, maybe somebody has the same issue.
    I just updated from 5.12.8 to 5.15.0. If I am using QML, I can connectToEndpoint only at the first time and all works just fine, but if I disconnectFromEndpoint, and try to connectToEndpoint again, connection status says connected, but ValueNodes don’t update anymore.
    Thanks

  37. Hello! Great tutorial!
    I was able to compile the windows version + docs + example with mingw 8.1.0 32bit, QT5.15.0, no problems here.
    But I also need the Android version and it’s not working using NDK 21.3:

    C:\Qt\5.15.0\mingw81_32\qtopcua>mingw32-make
    cd src\ && ( if not exist Makefile C:\Qt\5.15.0\android\bin\qmake.exe -o Makefile C:\Qt\5.15.0\mingw81_32\qtopcua\src\src.pro „QMAKE_CXXFLAGS=-I C:\OpenSSL-Win64\include -L C:\OpenSSL-Win64\lib“ ) && mingw32-make -f Makefile
    mingw32-make[1]: Entering directory ‚C:/Qt/5.15.0/mingw81_32/qtopcua/src‘
    cd opcua\ && ( if not exist Makefile C:\Qt\5.15.0\android\bin\qmake.exe -o Makefile C:\Qt\5.15.0\mingw81_32\qtopcua\src\opcua\opcua.pro „QMAKE_CXXFLAGS=-I C:\OpenSSL-Win64\include -L C:\OpenSSL-Win64\lib“ ) && mingw32-make -f Makefile
    Project MESSAGE: perl -w C:\Qt\5.15.0\android\bin\syncqt.pl -module QtOpcUa -version 5.15.0 -outdir C:/Qt/5.15.0/mingw81_32/qtopcua -builddir C:/Qt/5.15.0/mingw81_32/qtopcua C:/Qt/5.15.0/mingw81_32/qtopcua
    = C:/Qt/5.15.0/mingw81_32/qtopcua
    = C:/Qt/5.15.0/mingw81_32/qtopcua
    = C:/Qt/5.15.0/mingw81_32/qtopcua
    QtOpcUa: created fwd-include header(s) for /src/opcua/ { qopcuaglobal.h (1) }
    QtOpcUa: created fwd-include header(s) for /src/opcua/client/ { qopcuaaddnodeitem.h (2), qopcuaaddreferenceitem.h (2), qopcuaapplicationdescription.h (2), qopcuaapplicationidentity.h (2), qopcuaapplicationrecorddatatype.h (2), qopcuaargument.h (2), qopcuaattributeoperand.h (2), qopcuaauthenticationinformation.h (2), qopcuaaxisinformation.h (2), qopcuabackend_p.h (1), qopcuabinarydataencoding.h (2), qopcuabrowsepathtarget.h (2), qopcuabrowserequest.h (2), qopcuaclient.h (2), qopcuaclient_p.h (1), qopcuaclientimpl_p.h (1), qopcuacomplexnumber.h (2), qopcuacontentfilterelement.h (2), qopcuacontentfilterelementresult.h (2), qopcuadeletereferenceitem.h (2), qopcuadoublecomplexnumber.h (2), qopcuaelementoperand.h (2), qopcuaendpointdescription.h (2), qopcuaerrorstate.h (2), qopcuaeuinformation.h (2), qopcuaeventfilterresult.h (2), qopcuaexpandednodeid.h (2), qopcuaextensionobject.h (2), qopcuagdsclient.h (2), qopcuagdsclient_p.h (1), qopcualiteraloperand.h (2), qopcualocalizedtext.h (2), qopcuamonitoringparameters.h (2), qopcuamonitoringparameters_p.h (1), qopcuamultidimensionalarray.h (2), qopcuanode.h (2), qopcuanode_p.h (1), qopcuanodecreationattributes.h (2), qopcuanodecreationattributes_p.h (1), qopcuanodeids.h (1), qopcuanodeimpl_p.h (1), qopcuapkiconfiguration.h (2), qopcuaqualifiedname.h (2), qopcuarange.h (2), qopcuareaditem.h (2), qopcuareadresult.h (2), qopcuareferencedescription.h (2), qopcuarelativepathelement.h (2), qopcuasimpleattributeoperand.h (2), qopcuatype.h (1), qopcuausertokenpolicy.h (2), qopcuawriteitem.h (2), qopcuawriteresult.h (2), qopcuaxvalue.h (2) }
    QtOpcUa: created fwd-include header(s) for /src/opcua/core/ { qopcuaplugin.h (2), qopcuaprovider.h (2) }
    QtOpcUa: created fwd-include header(s) for /src/opcua/x509/ { openssl_symbols_p.h (1), qopcuakeypair.h (2), qopcuakeypair_p.h (1), qopcuax509certificatesigningrequest.h (2), qopcuax509certificatesigningrequest_p.h (1), qopcuax509distinguishedname.h (2), qopcuax509extension.h (2), qopcuax509extension_p.h (1), qopcuax509extensionbasicconstraints.h (2), qopcuax509extensionextendedkeyusage.h (2), qopcuax509extensionkeyusage.h (2), qopcuax509extensionsubjectalternativename.h (2), qopcuax509utils_p.h (1), qsslsocket_openssl11_symbols_p.h (1), qsslsocket_opensslpre11_symbols_p.h (1) }
    QtOpcUa: created version header
    QtOpcUa: created master header
    QtOpcUa: created headers.pri file
    mingw32-make[2]: Entering directory ‚C:/Qt/5.15.0/mingw81_32/qtopcua/src/opcua‘
    mingw32-make -f Makefile.Armeabi-v7a all
    mingw32-make[3]: Entering directory ‚C:/Qt/5.15.0/mingw81_32/qtopcua/src/opcua‘
    C:\Users\foliveira15\AppData\Local\Android\Sdk\ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++ -c -I C:\OpenSSL-Win64\include -L C:\OpenSSL-Win64\lib -O2 -mthumb -Oz -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wdate-time -Winconsistent-missing-override -D_REENTRANT -fPIC -DQT_NO_LINKED_LIST -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_OPCUA_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_NO_FOREACH -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I..\..\include -I..\..\include\QtOpcUa -I..\..\include\QtOpcUa\5.15.0 -I..\..\include\QtOpcUa\5.15.0\QtOpcUa -IC:\Qt\5.15.0\android\include\QtNetwork\5.15.0 -IC:\Qt\5.15.0\android\include\QtNetwork\5.15.0\QtNetwork -IC:\Qt\5.15.0\android\include\QtCore\5.15.0 -IC:\Qt\5.15.0\android\include\QtCore\5.15.0\QtCore -IC:\Qt\5.15.0\android\include -IC:\Qt\5.15.0\android\include\QtNetwork -IC:\Qt\5.15.0\android\include\QtCore -I.moc\armeabi-v7a -Ic:\utils\openssl-android-master\include -IC:\Qt\5.15.0\android\mkspecs\android-clang -o .obj\armeabi-v7a\qopcuaprovider.obj core\qopcuaprovider.cpp
    clang++: error: unsupported option ‚-fPIC‘ for target ‚x86_64-w64-windows-gnu‘
    mingw32-make[3]: *** [Makefile.Armeabi-v7a:2047: .obj\armeabi-v7a\qopcuaprovider.obj] Error 1
    mingw32-make[3]: Leaving directory ‚C:/Qt/5.15.0/mingw81_32/qtopcua/src/opcua‘
    mingw32-make[2]: *** [Makefile:48: armeabi-v7a-all] Error 2
    mingw32-make[2]: Leaving directory ‚C:/Qt/5.15.0/mingw81_32/qtopcua/src/opcua‘
    mingw32-make[1]: *** [Makefile:49: sub-opcua-make_first] Error 2
    mingw32-make[1]: Leaving directory ‚C:/Qt/5.15.0/mingw81_32/qtopcua/src‘
    mingw32-make: *** [Makefile:50: sub-src-make_first] Error 2

    Any ideas?

  38. Thank you so much for the installation guide.
    I successfully installed in ubuntu, but when I tried to run the examples, it said „qopen62541.h“ not found. I read through the Q&A, and could not find the same problem.
    You also mentioned that „The open62541 plugin is now built by default without requiring any additional setup.“
    So I am not sure if something is missing.
    Thank you very much for your help in advance! 😀

    • Okay, somehow the plugin was not installed. I manually copied “qopen62541.h” to the project I wanna build.
      Then I found that „open62541.h“ is missing, I dunno why, but I separately installed open62541, and „open62541.h“ showed up.
      Then open62541.pri is missing…. and I dunno how to fix it yet.
      Do you have the solution? Thank you!

      • I guess the error happens while building the simulation server for the waterpump example.

        Unfortunately, the mechanism in simulationserver.pro only works if you are using the distributed version from Qt for automation. Please try to change the path in line 10 of simulationserver.pro to the absolute path of your qtopcua repository clone.

  39. Hello I´m trying to compile it in mvs2017 64 with open62541. Qt version is 5.12.7 and pointing to qtopcua branch 5.12. When run qmake everything is working correctly, Open62541 y detected correctly. But when launch nmake I get a QT building error:
    c:\qt\5.12.7\msvc2017_64\qtopcua\src\opcua\client\qopcuabinarydataencoding.h(417): error C2664: ‚QString QString::arg(const QString &,int,QChar) const‘: el argumento 1 no puede convertirse de ‚QStringRef‘ a ‚qlonglong‘
    c:\qt\5.12.7\msvc2017_64\qtopcua\src\opcua\client\qopcuabinarydataencoding.h(417): note: No hay disponible ning£n operador de conversi¢n definido por el usuario que pueda realizar esta conversi¢n, o bien no se puede llamar al operador

    Do you have the solution? Thank you!

  40. I installed qt 5.15.0 on Windows 10
    I checked out branch 5.15.0 of qtopcua and run qmake..
    then i added the following 3 lines to .qmake.conf
    INCLUDEPATH +=“C:\Qt\Tools\OpenSSL\Win_x64\include“
    LIBS +=“C:\Qt\Tools\OpenSSL\Win_x64\lib\libssl.lib“
    LIBS +=“C:\Qt\Tools\OpenSSL\Win_x64\lib\libcrypto.lib“
    Then i run nmake and compile with MSVC 2015 64 bit
    It compiles well but then i get the following linker error:

    moc_qopcuausertokenpolicy.cpp
    moc_qopcuaprovider.cpp
    moc_qopcuaplugin.cpp
    moc_qopcuaclient.cpp
    moc_qopcuanode.cpp
    moc_qopcuatype.cpp
    moc_qopcuakeypair.cpp
    Code wird generiert…
    link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /OPT:REF /INCREMENTAL:NO /DLL /SUBSYSTEM:WINDOWS /VERSION:5.15 /MANIFEST:embed /OUT:..\..\lib\Qt5OpcUa.dll @C:\Users\U47851\AppData\Local\Temp\nm879A.tmp
    Bibliothek „..\..\lib\Qt5OpcUa.lib“ und Objekt „..\..\lib\Qt5OpcUa.exp“ werden erstellt.
    openssl_symbols.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol „“__declspec(dllimport) public: __cdecl QBasicMutex::QBasicMutex(void)“ (__imp_??0QBasicMutex@@QEAA@XZ)“ in Funktion „“void __cdecl `dynamic initializer for ’symbolResolveMutex“(void)“ (??__EsymbolResolveMutex@@YAXXZ)“.
    ..\..\lib\Qt5OpcUa.dll : fatal error LNK1120: 1 nicht aufgelöste Externe
    NMAKE : fatal error U1077: „“C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX86\x64\link.EXE““: Rückgabe-Code „0x460“
    Stop.
    NMAKE : fatal error U1077: „“C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX86\x64\nmake.exe““: Rückgabe-Code „0x2“
    Stop.
    NMAKE : fatal error U1077: „cd“: Rückgabe-Code „0x2“
    Stop.
    NMAKE : fatal error U1077: „cd“: Rückgabe-Code „0x2“
    Stop.

    I tried the same with MSCVC 2019 64 bit and get the same result.
    Any help would kindly be appreciated 🙂

  41. Hello,

    I am new in using QT and tried to install the Qt OPC-UA Plug-In on the following Virtual Machine:
    – Ubuntu (64-bit)
    – Pre-Installed QT-Version: Qt 5.12.8

    After using your given source code for Linux within the Linux-Terminal, I got the following Output:
    ________________________________________________________________________________
    maizi@xUbuntu-20:~$ git clone https://code.qt.io/qt/qtopcua.git
    Klone nach ‚qtopcua‘ …
    remote: Counting objects: 8997, done.
    remote: Compressing objects: 100% (4981/4981), done.
    remote: Total 8997 (delta 5653), reused 6388 (delta 3932)
    Empfange Objekte: 100% (8997/8997), 2.77 MiB | 798.00 KiB/s, Fertig.
    Löse Unterschiede auf: 100% (5653/5653), Fertig.
    maizi@xUbuntu-20:~$ cd qtopcua
    maizi@xUbuntu-20:~/qtopcua$ git checkout 5.12
    Branch ‚5.12‘ folgt nun Remote-Branch ‚5.12‘ von ‚origin‘.
    Zu neuem Branch ‚5.12‘ gewechselt
    maizi@xUbuntu-20:~/qtopcua$ mkdir build && cd build
    maizi@xUbuntu-20:~/qtopcua/build$ ~/Qt/5.12.0/gcc_64/bin/qmake ..
    bash: /home/maizi/Qt/5.12.0/gcc_64/bin/qmake: Datei oder Verzeichnis nicht gefunden
    maizi@xUbuntu-20:~/qtopcua/build$ make
    make: *** Es wurden keine Ziele angegeben und keine „make“-Steuerdatei gefunden. Schluss.
    maizi@xUbuntu-20:~/qtopcua/build$ sudo make install
    ________________________________________________________________________________

    A folder called „qtopcua“ was added to the home directory. But I am not able to include Qt OPC-UA Library within my project. Do you have the solution for this problem? Any help would be kindly appreciated.

    Thank you in advance!

    • Hello,
      according to the output, there is no qmake executable at the path you are specifying.
      Please make sure you use the right path for qmake (check with passing –version to it, you should see the version information).

      • Hello,

        Thank you for your tip. It works now.
        I have an additional Question refering Open62541:

        Do I need to install Open62541 first before using this Installationguide for Qt OPC UA ? Or is the Open62541 library included automaticly within this Installation?

        • Hello,
          the default way to build the open62541 backend uses the open62541 amalgamation release that comes with the Qt OPC UA source code.

  42. Hello,
    I Installed OPC UA for Windows MinGW32 at Qt 5.12.8 & 5.13. The installation was successful is showed. Also in „C:\Qt\Qt5.12.8\5.12.8\mingw73_32\qtopcua\build\plugins\opcua“ directory there necessary plugins
    1. libopen62541_backend.a
    2. libopen62541_backendd.a
    3. open62541_backend.dll
    4. open62541_backendd.dll

    I added QT += opcua in my .pro file but it showed
    „unknown module(s) in QT:opcua“

    I could not find where is the problem ?

    • The path looks like you have built Qt OPC UA inside your Qt installation instead of building it somewhere else and then installing it.

      • Now I have built outside of Qt installation. After that it automatically add a opcua folder in here C:\Qt\Qt5.12.8\5.12.8\mingw73_32\plugins
        Now there are two .dll file
        open62541_backend.dll
        open62541_backendd.dll

        But still when I run a project in Qt creator it showed
        „Project ERROR: Unknown module(s) in QT: opcua“

  43. In my
    C:\Qt\Qt5.12.8\5.12.8\mingw73_32\lib
    Qt5OpcUa.dll
    Qt5OpcUad.dll
    in C:\Qt\Qt5.12.8\5.12.8\mingw73_32\plugins
    libopen62541_backend.a
    libopen62541_backendd.a
    in C:\Qt\Qt5.12.8\5.12.8\mingw73_32\mkspecs\modules
    qt_plugin_open52541_backend
    in C:\Qt\Qt5.12.8\5.12.8\mingw73_32\qml\QtOpcUa
    libdeclarative_opcua.a
    libdeclarative_opcuad.a
    these files are missing in my main qt installation file.
    this is ok or I have to copy these files from qtopcua installation file.
    this my qtopcua installation path
    C:\qtopcua\qtopcua\build

    • Did you build and install the 5.12.8 branch for Qt 5.12.8 using the 5.12.8 qmake executable and the the 5.13 branch for Qt 5.13 using the 5.13 qmake executable?
      Please make sure you’re using the exact Qt version you used to build Qt OPC UA to build your project.

  44. I built & installed the 5.12 branch Qt 5.12.8 using the 5.12qmake executable and the 5.13 branch Qt 5.1338 using the 5.13qmake executable.

  45. Hello,

    my Operating System is:

    – Linux 64 Bit
    – Xubuntu 20.04
    – Qt 5.15.2

    I have tried to install the Qt OPC UA Plug-In Version 5.15.2 by using the following instructions:

    https://www.basyskom.de/building-qt-opc-ua-with-open62541/

    git clone https://code.qt.io/qt/qtopcua.git
    cd qtopcua
    git checkout 5.15.2
    mkdir build && cd build
    ~/Qt/5.15.2/gcc_64/bin/qmake ..
    make
    sudo make install

    After compiling the code with the Linux terminal, I get the following error message:

    In file included from /home/user/qtopcua/src/opcua/x509/qopcuax509certificatesigningrequest.cpp:38:
    /home/user/qtopcua/src/opcua/x509/openssl_symbols_p.h:59:10: fatal error: openssl/asn1.h: file or path not found
    59 | #include
    | ^~~~~~~~~~~~~~~~
    compilation terminated.
    make[2]: *** [Makefile:7415: .obj/qopcuax509certificatesigningrequest.o] Error 1
    make[2]: path „/home/user/qtopcua/build/src/opcua“ is left
    make[1]: *** [Makefile:49: sub-opcua-make_first] Error 2
    make[1]: path „/home/user/qtopcua/build/src“ wird verlassen
    make: *** [Makefile:50: sub-src-make_first] Error 2

    I checked my openssl version. I have installed openssl 1.1 .
    So what is the reason why it is not finding the openssl/asn1.h file ?
    Are there any problems linked with the Qt Version 5.15.2 ?

    How I can I solve this ?

    Thank you very much!

  46. Hello Basyskom,

    i build qtopcua on linux sucessfully with Qt5.13.2 and it works fine.
    I also want to use in on an embedded ARM device also running Qt15.13.2
    I have created a kit in the Qt Creator and can compile and download and debug on the external arm board perfectly.
    Now i want to use Qtopcua also on the arm board.
    If i install it using the arm boards toolchain i get the following error:
    MS-7823:/opt/Qt/5.13.2/Automation/sources/qtopcua/buildz$ /tools/Xilinx/petalinux_sdk/sysroots/x86_64-petalinux-linux/usr/bin/qmake ..
    Project ERROR: Cannot run compiler ‚aarch64-xilinx-linux-g++ -march=armv8-a+crc -mtune=cortex-a72.cortex-a53 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security‘. Output:
    ===================
    ===================
    Maybe you forgot to setup the environment?

    Any ideas?
    Maybe you could add a little explanation how to compile and install for embedded buildchains.

    Thanks you very much

    Kindest Regards
    Erik

  47. Hello,
    I try to install QtOpcUa on a new machine with MSVC 64 bits on Windows always. This time, the installation is not working. First the „qmake“ command didn’t find the „cl“ exe. So I add to my PATH variable the folder of Visual Studio in which it is. And now when I execute „nmake“ it failed at the beginning because it didn’t find the „type_straits.h“ file whereas it is on another folder of Visual Studio. I add to the PATH variable the folder in which there is this file, but the error is still here.
    Any idea to unblock me? Thank you in advance

  48. I am trying to build OPC UA for Android on Arch Linux.
    Currently it only works without encryption support, so when I build my application I am getting „The open62541 plugin has been built without encryption support“.
    When running qmake I get:
    „mbedtls ………………………….. no“
    Checking the config.log file there’s an error: „/home/steve/Qt/5.15.2/qtopcua/config.tests/mbedtls/main.cpp:37:10: fatal error: ‚mbedtls/x509.h‘ file not found“
    The package mbedtls-2.27.0-1 is installed. Any idea what I need to do?

    • To build Qt OPC UA for android, you will need a mbedTLS build for android, not for the host system where the cross build is done.
      The path to the mbedTLS includes and libraries must be available in the environment. Usually, the easiest way is to pass them in the qmake call via QMAKE_CXXFLAGS+=“-I/path/to/includes -L/path/to/libs“.

      • Thank you very much for your help.
        I have now downloaded mbedtls 2.27.0 and built it by calling
        „cmake -DCMAKE_TOOLCHAIN_FILE=/home/steve/Android/Sdk/ndk/21.3.6528147/build/cmake/android.toolchain.cmake -DANDROID_NDK=/home/steve/Android/Sdk/ndk/21.3.6528147 -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=“arm64-v8a“ -DENABLE_TESTING=false -DANDROID_NATIVE_API_LEVEL=21 ../mbedtls-mbedtls-2.27.0/
        cmake –build .“
        Then I ran qmake, pointing to the compiled mbedtls by calling:
        „~/Qt/5.15.2/android/bin/qmake QMAKE_CXXFLAGS+=“-I/home/steve/build-mbedtls-android/build/include/mbedtls -L/home/steve/build-mbedtls-android/build/library/“ ..“

        But I am still getting the exact same error:
        „fatal error: ‚mbedtls/x509.h‘ file not found“
        In the config.log, the supplied paths aren’t listed under the „Global lib dirs“ and „Global inc dirs“.
        I also tried copying the files under include/ and library/ to paths that are listed under the Global dirs respectively, which resulted in a different error:
        „…/aarch64-linux-android/bin/ld: cannot find -lmbedx509
        …/aarch65-linux-android/bin/ld: cannot find -lmbedcrypto“

      • After days of trying I am still stuck on this problem.
        While specifying the include files works, I just cannot get qmake/make to accept the library files. In config.log, I’m always getting „cannot find -mbedx509“ and „cannot find -lmbedcrypto“.
        When running make anyways it even spits out this warning: „argument unused during compilation: ‚-L/home/steve/build-mbedtls-android/build/library/‘ [-Wunused-command-line-argument]“. Copying the library files to a global lib include directory doesn’t do the trick either.

        I need this to work but I cannot spend an unlimited amount of time on this issue. Is there a way to get further support on this?

        • Have you always removed all files from the build directory before running qmake again?
          Please try to set QMAKE_CFLAGS to the same values as QMAKE_CXXFLAGS.

          If this doesn’t work, you could also attempt to set your compiler’s environment variables for C and CXX flags.

          • Yes, I clear the build directory every time.
            Setting QMAKE_CFLAGS did not change anything.

            I tried adding the flags (CFLAGS and CXXFLAGS) to the Makefile of the mbedtls tests and building them by calling make. It did recognize the include files, but apparently not the library files, resulting in the same linker errors as before: „cannot find -lmbedx509“ and „cannot find -lmbedcrypto“.

          • Our integrator has worked out a way to get it working.

            Parameters for the mbedTLS build:
            cmake -DCMAKE_TOOLCHAIN_FILE=/opt/android/android-ndk-r21e/build/cmake/android.toolchain.cmake -DANDROID_NDK=/opt/android/android-ndk-r21e/ -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=false -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_ABI="arm64-v8a" ..
            Parameters for the Qt OPC UA build:
            qmake ../ EXTRA_INCLUDEPATH+="/app/src/mbedtls/install/dyn/usr/local/include/" EXTRA_LIBDIR+="/app/src/mbedtls/install/dyn/usr/local/lib" ANDROID_ABIS="arm64-v8a" -- -no-feature-gds

            The EXTRA_INCLUDEPATH and EXTRA_LIBDIR variables in the qmake call were the key, all other variables didn’t work.

          • Thank you very much for takting a deeper look into this issue! With the added variables I was able to build open62541 with encryption support.

            Unfortunately though, when I build and run my application, it is unable to load the OPC UA plugin, although it is listed as available:
            qt.opcua: Failed to load OPC UA plugin: „open62541“
            qt.opcua: Available plugins: („open62541“)

            When I try to connect to a server, the application crashes.

          • Being unable to load a plugin usually indicates a dependency problem (missing library). Do you have ldd or some similar tool available to check which other libraries are runtime requirements for the open62541 plugin and if they are all available?

          • Yes, ldd is available. But how do I use that when building for Android? When I run ldd on the file libplugins_opcua_open62541_backend_arm64-v8a.so I’m getting the message that the program isn’t linked dynamically.

          • I cannot tell you why, but after poking at the problem for a while it suddenly works.
            So thank you again very very much for your help!

  49. Hi. I’m trying to build qtopcua for Qt 6.2.0 (Mingw 8.1-64 bit) on Windows 10. I cloned the repository and switched to the 6.2.0 branch. CMake .. complains that it could not find a proper version of the Qt6 module. After detailed search I found that QtOpcUa expects 32 bit architecture, but my Qt6 is 64-bit (the online installer doesn’t provide 32 version for Qt 6.2.0). Does qtopcua support mingw 8.1-64 bit on windows 10 for qt6 or I have to compile 32-version of Qt6 from source?
    Thanks!

    • Hello,
      32 bit or 64 bit should not be a problem.
      How do you pass your Qt version into CMake? Setting CMAKE_PREFIX_PATH to (Your Qt install path)/6.2.0/mingw64 should do the trick.
      Make sure to check out the exact Qt OPC UA branch corresponding to your Qt installation or change the version in .cmake.conf to the version number of your installed Qt 6.

  50. Struggling to build and install on Win10 for 5.15.6 install for both mingw32 and 64. I’ve tried cloning to:
    c:\Qt\5.15.6\mingw81_[32 or 64]\ and c:\Qt\5.15.6\mingw81_[32 or 64]\plugins <<qmake „INCLUDEPATH+=c:\progra[~1 or ~2]\OpenSSL-Win[32 or 64]\include“ ..

    When I try 64 bit I use mingw32-make as mingw64-make does not exist but I am in the correct shell when I do the call.

    In general, I think the call to mingw32-make is working. However when I run mingw32-make install I see errors and I always end up with Project Error: Unknown Module: opcua.

    32-bit
    C:\QtCommercial\5.15.6\mingw81_32\bin\qmake.exe -install sed -e „s,C:/QtCommercial/5.15.6/mingw81_32/plugins/qtopcua/build/lib,C:/QtCommercial/5.15.6/mingw81_32/lib,g“ -e „s,C:\\\\QtCommercial\\\\5.15.6\\\\mingw81_32\\\\plugins\\\\qtopcua\\\\build\\\\lib,C:\\\\QtCommercial\\\\5.15.6\\\\mingw81_32\\\\lib,gi“ ..\..\build\lib\pkgconfig\Qt5OpcUa.pc > C:\QtCommercial\5.15.6\mingw81_32\lib\pkgconfig\Qt5OpcUa.pc
    ..\..\build\lib\pkgconfig\Qt5OpcUa.pc: No such file or directory
    mingw32-make[3]: *** [Makefile.Release:7594: install_target] Error 1
    mingw32-make[3]: Leaving directory ‚C:/QtCommercial/5.15.6/mingw81_32/plugins/qtopcua/build/src/opcua‘
    mingw32-make[2]: *** [Makefile:55: release-install] Error 2
    mingw32-make[2]: Leaving directory ‚C:/QtCommercial/5.15.6/mingw81_32/plugins/qtopcua/build/src/opcua‘
    mingw32-make[1]: *** [Makefile:64: sub-opcua-install_subtargets] Error 2
    mingw32-make[1]: Leaving directory ‚C:/QtCommercial/5.15.6/mingw81_32/plugins/qtopcua/build/src‘
    mingw32-make: *** [Makefile:65: sub-src-install_subtargets] Error 2

    64-bit
    C:\QtCommercial\5.15.6\mingw81_64\bin\qmake.exe -install sed -e „s,C:/QtCommercial/5.15.6/mingw81_64/plugins/qtopcua/build/lib,C:/QtCommercial/5.15.6/mingw81_64/lib,g“ -e „s,C:\\\\QtCommercial\\\\5.15.6\\\\mingw81_64\\\\plugins\\\\qtopcua\\\\build\\\\lib,C:\\\\QtCommercial\\\\5.15.6\\\\mingw81_64\\\\lib,gi“ ..\..\build\lib\pkgconfig\Qt5OpcUa.pc > C:\QtCommercial\5.15.6\mingw81_64\lib\pkgconfig\Qt5OpcUa.pc
    ..\..\build\lib\pkgconfig\Qt5OpcUa.pc: No such file or directory
    mingw32-make[3]: *** [Makefile.Release:7594: install_target] Error 1
    mingw32-make[3]: Leaving directory ‚C:/QtCommercial/5.15.6/mingw81_64/plugins/qtopcua/build/src/opcua‘
    mingw32-make[2]: *** [Makefile:55: release-install] Error 2
    mingw32-make[2]: Leaving directory ‚C:/QtCommercial/5.15.6/mingw81_64/plugins/qtopcua/build/src/opcua‘
    mingw32-make[1]: *** [Makefile:64: sub-opcua-install_subtargets] Error 2
    mingw32-make[1]: Leaving directory ‚C:/QtCommercial/5.15.6/mingw81_64/plugins/qtopcua/build/src‘
    mingw32-make: *** [Makefile:65: sub-src-install_subtargets] Error 2

    Please advise!

    • Hello Rich,
      please try to build directly in the root directory of the repository without using a separate build directory.
      The source code should not be cloned directly into your Qt installation, it is better to put it outside
      and have make install take care of putting the necessary files where they belong.

      • Hi,
        i see the below error
        qt.opcua.plugins.open62541: Unable to send publish request

        I am running qt opcua on Qt 5.12 with Yocto based dunfell OS. I have the application running good for a quite few hours with out any issue. But i see the above error at times and my app immediately quits with out any errors. All i see is Client gets disconnected at the same time.

        Can you insight your thoughts on the same?

  51. Hello,

    Would it be possible to update the building steps for Qt 6.x.x using cmake?

    Everything seems to go well in the build process with MSVC2019 Qt 6.2.1 according to the above instructions. But instead of nmake i use visual studio to build the „INSTALL“ solution. I seem to get all the qml/qtopcua.. opcua/plugins/open62..dll etc.

    After that I can build the example „opcuaviewer“ and run it. But when trying to connect I get:
    „Failed to load OPC UA plugin: open62541“
    „Available plugins: QList(62541)“

    I got the qt opc ua to work with 5.x.x before, examples etc. needed manual moving etc. but for some reason I am at a loss in here. I am not an expert in this area, but would like to test the new qt opc ua on 6.x. I can see someone else has had this problem too, but I did not seem to do the right kind of „poking“.

    Thanks,
    Br. Kari

  52. Hi, I’m trying to build Qtopcua 5.12.12 for qt5.12.12 and mingw32 with strawbery perl installed.
    i dont use git so i just downloaded the zip file from github ( version 5.12.12) and put its content in „f:/QT/qtopcua“ folder and followed your instruction (mkdir build …) but i got stuck with this error multiple times :
    „In file included from core\qopcuaprovider.cpp:37:0:
    core\qopcuaplugin.h:40:10: fatal error: QtOpcUa/qopcuaglobal.h: No such file or directory
    #include
    ^~~~~~~~~~~~~~~~~~~~~~~~“
    what am i missing here ?

    • Hi, Please try using a build directory on the same level as the qtopcua folder.
      Due to a change in qmake, the build directory inside the qtopcua folder doesn’t seem to be supported anymore, at least for MinGW.

  53. Hi,

    I am on 5.13.2. I followed the above instruction but am getting the following error:

    cd src/ && ( test -e Makefile || /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtbase/bin/qmake -o Makefile /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua/src/src.pro ) && make -f Makefile
    make[1]: Entering directory ‚/home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua/build/src‘
    cd opcua/ && ( test -e Makefile || /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtbase/bin/qmake -o Makefile /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua/src/opcua/opcua.pro ) && make -f Makefile
    Project MESSAGE: perl -w /home/test123/opt/cross-compiler/qt5.13.2/qt5/qtbase/bin/syncqt.pl -module QtOpcUa -version 5.13.2 -outdir /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua/build -builddir /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua/build /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua
    = /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua
    = /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua/build
    = /home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua/build
    QtOpcUa: created fwd-include header(s) for /src/opcua/ { qopcuaglobal.h (1) }
    QtOpcUa: created fwd-include header(s) for /src/opcua/client/ { qopcuaaddnodeitem.h (2), qopcuaaddreferenceitem.h (2), qopcuaapplicationdescription.h (2), qopcuaapplicationidentity.h (2), qopcuaargument.h (2), qopcuaattributeoperand.h (2), qopcuaauthenticationinformation.h (2), qopcuaaxisinformation.h (2), qopcuabackend_p.h (1), qopcuabinarydataencoding.h (2), qopcuabrowsepathtarget.h (2), qopcuabrowserequest.h (2), qopcuaclient.h (2), qopcuaclient_p.h (1), qopcuaclientimpl_p.h (1), qopcuacomplexnumber.h (2), qopcuacontentfilterelement.h (2), qopcuacontentfilterelementresult.h (2), qopcuadeletereferenceitem.h (2), qopcuadoublecomplexnumber.h (2), qopcuaelementoperand.h (2), qopcuaendpointdescription.h (2), qopcuaerrorstate.h (2), qopcuaeuinformation.h (2), qopcuaeventfilterresult.h (2), qopcuaexpandednodeid.h (2), qopcuaextensionobject.h (2), qopcualiteraloperand.h (2), qopcualocalizedtext.h (2), qopcuamonitoringparameters.h (2), qopcuamonitoringparameters_p.h (1), qopcuamultidimensionalarray.h (2), qopcuanode.h (2), qopcuanode_p.h (1), qopcuanodecreationattributes.h (2), qopcuanodecreationattributes_p.h (1), qopcuanodeids.h (1), qopcuanodeimpl_p.h (1), qopcuapkiconfiguration.h (2), qopcuaqualifiedname.h (2), qopcuarange.h (2), qopcuareaditem.h (2), qopcuareadresult.h (2), qopcuareferencedescription.h (2), qopcuarelativepathelement.h (2), qopcuasimpleattributeoperand.h (2), qopcuatype.h (1), qopcuausertokenpolicy.h (2), qopcuawriteitem.h (2), qopcuawriteresult.h (2), qopcuaxvalue.h (2) }
    QtOpcUa: created fwd-include header(s) for /src/opcua/core/ { qopcuaplugin.h (2), qopcuaprovider.h (2) }
    QtOpcUa: created version header
    QtOpcUa: created master header
    QtOpcUa: created headers.pri file
    Project ERROR: Could not find feature ns0idnames.
    Makefile:48: recipe for target ’sub-opcua-make_first‘ failed
    make[1]: *** [sub-opcua-make_first] Error 3
    make[1]: Leaving directory ‚/home/test123/opt/cross-compiler/qt5.13.2/buster-64/qtopcua/build/src‘
    Makefile:49: recipe for target ’sub-src-make_first‘ failed
    make: *** [sub-src-make_first] Error 2

    Any idea why? Thanks

    • Hi, which branch/tag of the Qt OPC UA repository are you trying to build for Qt 5.13.2?
      There have been quite a few changes to qmake and the project structure and some of them break backwards compatibility for the project (if I remember correctly).

  54. i installed perl then openssl
    then fallowed your cmds for qt 15.5.2
    I find servers, I get end points but can not connect to it:
    qt.opcua.plugins.open62541: The open62541 plugin has been built without encryption support
    qt.opcua.plugins.open62541: Unsupported security policy: „http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15“

    I’m a beginner and I don’t know what to do

    • The Qt OPC UA module uses the mbedTLS library in Qt 5.15, OpenSSL support is only available starting with Qt 6.

  55. Hi Frank,

    Hope you are doing great..

    Trying to build OPCUA SDK with the MinGW 8.1 & Qt 5.15.10 on my Windows 10 PC , but getting errors. Your help is much appreciated.

    errors:
    C:\Qt\5.15.10\Automation\sources\qtopcua\src\plugins\opcua\uacpp\quacppbackend.h:33: error: private/qopcuabackend_p.h: No such file or directory
    In file included from C:\Qt\5.15.10\Automation\sources\qtopcua\src\plugins\opcua\uacpp\quacppclient.cpp:30:
    C:\Qt\5.15.10\Automation\sources\qtopcua\src\plugins\opcua\uacpp\quacppbackend.h:33:10: fatal error: private/qopcuabackend_p.h: No such file or directory
    #include

    • This error seems to be related to the Unified Automation backend – Please get in touch with the commercial support.

  56. Hi,
    I use Qt 5.15.2,
    When I use nmake in msvc 2019 64bit cmd, I get a error
    EST:embed /OUT:..\..\lib\Qt5OpcUa.dll @C:\Users\ADMINI~1\AppData\Local\Temp\nm9B93.tmp
    Qt5Core.lib(Qt5Core.dll) : fatal error LNK1112:module machine type ‚x64‘ conflicts with target machine type ‚X86‘.
    It was nmake successed in msvc 2019 32bit ,
    How can I solve it?
    Thank you.

    • Looks like your Qt libraries are 64 bit but you’re attempting to link them into a 32 bit build of Qt OPC UA.
      Please make sure to source the vcvars for the right architecture.

  57. When I execute qmake.

    It show me

    C:\Qt\6.5.0\mingw_64\qtopcua\build>qmake ..
    C:/Qt/6.5.0/mingw_64/qtopcua/.qmake.conf:1: Cannot find feature qt_build_config
    C:/Qt/6.5.0/mingw_64/qtopcua/.qmake.conf:1: Cannot find feature qt_build_config
    C:/Qt/6.5.0/mingw_64/qtopcua/qtopcua.pro:4: Cannot find feature qt_parts
    C:/Qt/6.5.0/mingw_64/qtopcua/qtopcua.pro:4: Cannot find feature qt_parts
    C:/Qt/6.5.0/mingw_64/qtopcua/qtopcua.pro:4: Cannot find feature qt_parts

    What should I do.

  58. Hi, i’m new to Qt and found out about this page.
    I’m trying to understand if it’s possible to use this QtOpcUa library in my python project (client side), but is seems its all c++ related.
    By the way, i’m using PySide6 for my project.
    I’ve tried to find an answer on the web but im confused, can you help me?

    • I can’t answer this. We are not using Qt OPC UA with Python and so far I have not been in contact with people that do.

  59. Hello,
    I am trying to build the Qt OPC UA for QT 6.1. T qmake did not report any problem:
    ~/Documents/OPC/qtopcua2/qtopcua/build$ ~/Qt/6.1.1/gcc_64/bin/qmake ..

    Running configuration tests…
    Done running configuration tests.

    Configure summary:

    Qt Opcua:
    Open62541 ………………………… yes
    Unified Automation C++ SDK …………. no
    Support for namespace 0 NodeId names … yes
    Namespace 0 NodeIds generator ………. no
    mbedtls ………………………….. no
    Support for global discovery server …. yes

    Qt is now configured for building. Just run ‚make‘.
    Once everything is built, you must run ‚make install‘.
    Qt will be installed into ‚/home/ksi/Qt/6.1.1/gcc_64‘.

    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.

    but the make crashed because of missing OpenGL library:
    g++ -Wl,–enable-new-dtags -Wl,-rpath,/home/ksi/Qt/6.1.1/gcc_64/lib -o basic .obj/main.o .obj/qrc_qml.o /home/ksi/Qt/6.1.1/gcc_64/lib/libQt6Quick.so -lGLX -lOpenGL /home/ksi/Qt/6.1.1/gcc_64/lib/libQt6OpenGL.so /home/ksi/Qt/6.1.1/gcc_64/lib/libQt6Gui.so /home/ksi/Qt/6.1.1/gcc_64/lib/libQt6QmlModels.so /home/ksi/Qt/6.1.1/gcc_64/lib/libQt6Qml.so -pthread /home/ksi/Qt/6.1.1/gcc_64/lib/libQt6Network.so /home/ksi/Qt/6.1.1/gcc_64/lib/libQt6Core.so -lpthread -lGL
    /usr/bin/ld: cannot find -lOpenGL
    collect2: error: ld returned 1 exit status
    make[5]: *** [Makefile:75: basic] Error 1
    make[5]: Leaving directory ‚/home/ksi/Documents/OPC/qtopcua2/qtopcua/build/src/imports/doc/snippets/basic‘
    make[4]: *** [Makefile:47: sub-basic-make_first] Error 2
    make[4]: Leaving directory ‚/home/ksi/Documents/OPC/qtopcua2/qtopcua/build/src/imports/doc/snippets‘
    make[3]: *** [Makefile:47: sub-snippets-make_first] Error 2
    make[3]: Leaving directory ‚/home/ksi/Documents/OPC/qtopcua2/qtopcua/build/src/imports/doc‘
    make[2]: *** [Makefile:48: sub-doc-make_first] Error 2
    make[2]: Leaving directory ‚/home/ksi/Documents/OPC/qtopcua2/qtopcua/build/src/imports‘
    make[1]: *** [Makefile:99: sub-imports-make_first] Error 2
    make[1]: Leaving directory ‚/home/ksi/Documents/OPC/qtopcua2/qtopcua/build/src‘
    make: *** [Makefile:50: sub-src-make_first] Error 2

    The only OpenGL.so library I found is in the package „libopengl-perl“ and is already installed.
    Can you tell me, which package must I install to successfully build the Qt OPC UA? Is there any list of package dependencies?
    Regards,
    Karel

    • Hello,
      since Qt 6.0, CMake ist the new official build system and building the module via qmake is no longer officially supported.
      If the missing library is still required with the CMake based built, please try to install libgl1-mesa-dev.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Weitere Blogartikel

basysKom Newsletter

We collect only the data you enter in this form (no IP address or information that can be derived from it). The collected data is only used in order to send you our regular newsletters, from which you can unsubscribe at any point using the link at the bottom of each newsletter. We will retain this information until you ask us to delete it permanently. For more information about our privacy policy, read Privacy Policy