Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Why Qt creator say "use of undeclared identifier 'QSslSocket'", but it exists.
Forum Updated to NodeBB v4.3 + New Features

Why Qt creator say "use of undeclared identifier 'QSslSocket'", but it exists.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
28 Posts 4 Posters 7.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    senmx
    wrote on last edited by senmx
    #1

    error: use of undeclared identifier 'QSslSocket'

    code:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QSslSocket>
    
    int main(int argc, char *argv[]) {
    
        qDebug() << "Device supports OpenSSL: " << QSslSocket::supportsSsl();
    
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        const QUrl url(QStringLiteral("qrc:/main.qml"));
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                         &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
        engine.load(url);
    
        return app.exec();
    }
    
    

    I tried:

    1. check in /usr/local/Qt-5.15.1-android/include

    [sen@x include]$ find . -type f -name "qsslsocket.h"
    ./QtNetwork/qsslsocket.h
    

    2. No problem in the old version(Qt 5.13.2)

    test.pro:

    QT += quick
    QT += network
    
    CONFIG += c++11
    ...
    
    jsulmJ Pablo J. RoginaP 2 Replies Last reply
    0
    • S senmx

      error: use of undeclared identifier 'QSslSocket'

      code:

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      #include <QSslSocket>
      
      int main(int argc, char *argv[]) {
      
          qDebug() << "Device supports OpenSSL: " << QSslSocket::supportsSsl();
      
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
          QGuiApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
          const QUrl url(QStringLiteral("qrc:/main.qml"));
          QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                           &app, [url](QObject *obj, const QUrl &objUrl) {
              if (!obj && url == objUrl)
                  QCoreApplication::exit(-1);
          }, Qt::QueuedConnection);
          engine.load(url);
      
          return app.exec();
      }
      
      

      I tried:

      1. check in /usr/local/Qt-5.15.1-android/include

      [sen@x include]$ find . -type f -name "qsslsocket.h"
      ./QtNetwork/qsslsocket.h
      

      2. No problem in the old version(Qt 5.13.2)

      test.pro:

      QT += quick
      QT += network
      
      CONFIG += c++11
      ...
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @senmx When do you get this error: while building your project?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • jsulmJ jsulm

        @senmx When do you get this error: while building your project?

        S Offline
        S Offline
        senmx
        wrote on last edited by
        #3

        @jsulm No, It hasn't been compiled yet, and qt creator reports an error directly.

        jsulmJ 1 Reply Last reply
        0
        • S senmx

          @jsulm No, It hasn't been compiled yet, and qt creator reports an error directly.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @senmx OK, then this comes from code model (clang) - it often reports false positive for what ever reason. If you do not want to use it disable the plug-in ClangCodeModel in Help/About Plugins...

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          2
          • jsulmJ jsulm

            @senmx OK, then this comes from code model (clang) - it often reports false positive for what ever reason. If you do not want to use it disable the plug-in ClangCodeModel in Help/About Plugins...

            S Offline
            S Offline
            senmx
            wrote on last edited by senmx
            #5

            @jsulm Thanks. I found that using the old version is normal, I don't know why. My new version of qt is compiled by myself after downloading the opensource code, and there is this header file under it.

            1 Reply Last reply
            0
            • S senmx

              error: use of undeclared identifier 'QSslSocket'

              code:

              #include <QGuiApplication>
              #include <QQmlApplicationEngine>
              #include <QSslSocket>
              
              int main(int argc, char *argv[]) {
              
                  qDebug() << "Device supports OpenSSL: " << QSslSocket::supportsSsl();
              
                  QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
              
                  QGuiApplication app(argc, argv);
              
                  QQmlApplicationEngine engine;
                  const QUrl url(QStringLiteral("qrc:/main.qml"));
                  QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                                   &app, [url](QObject *obj, const QUrl &objUrl) {
                      if (!obj && url == objUrl)
                          QCoreApplication::exit(-1);
                  }, Qt::QueuedConnection);
                  engine.load(url);
              
                  return app.exec();
              }
              
              

              I tried:

              1. check in /usr/local/Qt-5.15.1-android/include

              [sen@x include]$ find . -type f -name "qsslsocket.h"
              ./QtNetwork/qsslsocket.h
              

              2. No problem in the old version(Qt 5.13.2)

              test.pro:

              QT += quick
              QT += network
              
              CONFIG += c++11
              ...
              
              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @senmx as a side note, if that's the whole code of your "main.cpp", the #include <QSslSockect> statement seems superfluous given there are no references to such class later in the code.

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              S 1 Reply Last reply
              0
              • Pablo J. RoginaP Pablo J. Rogina

                @senmx as a side note, if that's the whole code of your "main.cpp", the #include <QSslSockect> statement seems superfluous given there are no references to such class later in the code.

                S Offline
                S Offline
                senmx
                wrote on last edited by
                #7

                @Pablo-J-Rogina Thanks.This is all the code, the old version is normal. I just write a test code casually, and raise this question by the way.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi,

                  Since you build Qt yourself, did you activate the OpenSSL option ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  S 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Hi,

                    Since you build Qt yourself, did you activate the OpenSSL option ?

                    S Offline
                    S Offline
                    senmx
                    wrote on last edited by senmx
                    #9

                    @SGaist What option activate and how?
                    This is my compile shell:

                    #!/bin/bash
                    #https://doc.qt.io/qt-5/android-building.html
                    
                    cd /home/sen/soft/qt-everywhere-src-5.15.1
                    
                    ./configure -xplatform android-clang -prefix /usr/local/Qt-5.15.1-android --disable-rpath -nomake tests -nomake examples -android-ndk $ANDROID_NDK_HOME -android-sdk $ANDROID_SDK_HOME -no-warnings-are-errors
                    make -j12
                    make install
                    
                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      You have the complete list of option if you call configure --help.

                      You should also check the configure summary to see what options/features are enabled.

                      And finally, if you want to build for Android with OpenSSL, you need an Android build of OpenSSL.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • S Offline
                        S Offline
                        senmx
                        wrote on last edited by senmx
                        #11

                        ./configure --help
                        ...
                        -no-openssl .......... Do not use OpenSSL [default on Apple and WinRT]
                        -openssl-linked ...... Use OpenSSL and link to libssl [no]
                        -openssl-runtime ..... Use OpenSSL and dynamically load libssl [auto]

                        I have now turned on this option and recompile

                          1 #!/bin/bash
                          2 #https://doc.qt.io/qt-5/android-building.html
                          3 #https://doc.qt.io/qt-5/ssl.html
                          4 
                          5 cd /home/sen/soft/qt-everywhere-src-5.15.1
                          6 make clean
                          7 OPENSSL_LIBS='-L/home/sen/github/c/openssl-1.1.1g -lssl -lcrypto' ./configure -xplatform android-clang -prefix /usr/local/Qt-5.15.1-android --disable-rpath -nomake tests -nomake examples -android-ndk $ANDROID_NDK_HOME -android-sdk $AND    ROID_SDK_HOME -no-warnings-are-errors -openssl-linked
                          8 make -j12
                          9 make install
                        

                        on configure:

                        ERROR: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && !features.schannel && libs.openssl' failed.
                        
                        jsulmJ 1 Reply Last reply
                        0
                        • S senmx

                          ./configure --help
                          ...
                          -no-openssl .......... Do not use OpenSSL [default on Apple and WinRT]
                          -openssl-linked ...... Use OpenSSL and link to libssl [no]
                          -openssl-runtime ..... Use OpenSSL and dynamically load libssl [auto]

                          I have now turned on this option and recompile

                            1 #!/bin/bash
                            2 #https://doc.qt.io/qt-5/android-building.html
                            3 #https://doc.qt.io/qt-5/ssl.html
                            4 
                            5 cd /home/sen/soft/qt-everywhere-src-5.15.1
                            6 make clean
                            7 OPENSSL_LIBS='-L/home/sen/github/c/openssl-1.1.1g -lssl -lcrypto' ./configure -xplatform android-clang -prefix /usr/local/Qt-5.15.1-android --disable-rpath -nomake tests -nomake examples -android-ndk $ANDROID_NDK_HOME -android-sdk $AND    ROID_SDK_HOME -no-warnings-are-errors -openssl-linked
                            8 make -j12
                            9 make install
                          

                          on configure:

                          ERROR: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && !features.schannel && libs.openssl' failed.
                          
                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @senmx Is /home/sen/github/c/openssl-1.1.1g the Android build?
                          Check the config.log file to see why exactly it failed.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          S 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @senmx Is /home/sen/github/c/openssl-1.1.1g the Android build?
                            Check the config.log file to see why exactly it failed.

                            S Offline
                            S Offline
                            senmx
                            wrote on last edited by
                            #13

                            @jsulm config.log:
                            https://drive.google.com/file/d/1lvrOXPgVWjvnfGV5U7TaMqPEJYh0leLF/view?usp=sharing

                            jsulmJ 1 Reply Last reply
                            0
                            • S senmx

                              @jsulm config.log:
                              https://drive.google.com/file/d/1lvrOXPgVWjvnfGV5U7TaMqPEJYh0leLF/view?usp=sharing

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @senmx You did not answer my question.

                              Did you check the config.log by yourself first?
                              Because if you check it you see

                              > main.cpp:2:10: fatal error: 'openssl/ssl.h' file not found
                              > #include <openssl/ssl.h>
                              

                              So, it could not find SSL header.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              2
                              • S Offline
                                S Offline
                                senmx
                                wrote on last edited by senmx
                                #15

                                @jsulm
                                I saw it, but I didn’t understand it. The first thing I saw from top to bottom was:

                                > main.cpp:7:8: error: Intel CET not available
                                > # error Intel CET not available
                                > ^
                                > 1 error generated.
                                > make: *** [Makefile:191:main.o] 错误 1
                                test config.qtbase.tests.intelcet FAILED
                                

                                Anyway, something is missing, I don’t know what is missing.

                                Could not find openssl/ssl.h,but:

                                [sen@x openssl]$ find /usr/include/openssl/ -type f -name "ssl.h"
                                /usr/include/openssl/ssl.h
                                

                                I have compiled link library files in this directory:

                                /home/sen/github/c/openssl-1.1.1g
                                
                                libssl_1_1.so
                                libcrypto_1_1.so
                                
                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  How did you build OpenSSL for Android ?

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  S 1 Reply Last reply
                                  0
                                  • SGaistS SGaist

                                    How did you build OpenSSL for Android ?

                                    S Offline
                                    S Offline
                                    senmx
                                    wrote on last edited by
                                    #17

                                    @SGaist
                                    according to Qt doc:

                                    #!/bin/sh
                                    
                                    export HOST=linux-x86_64
                                    export PATH="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$HOST/bin":$PATH
                                    
                                    cd /home/sen/github/c/openssl-1.1.1g
                                    ./Configure shared android-arm -D__ANDROID_API__=21
                                    make -j12 SHLIB_VERSION_NUMBER= SHLIB_EXT=_1_1.so build_libs
                                    
                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      Then why are you mixing your system installation with your custom OpenSSL build.

                                      By the way, your Intel CET is likely due to a line that starts with a #. My guess is that this is a comme but Python style rather than C/C++ style.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      S 1 Reply Last reply
                                      0
                                      • SGaistS SGaist

                                        Then why are you mixing your system installation with your custom OpenSSL build.

                                        By the way, your Intel CET is likely due to a line that starts with a #. My guess is that this is a comme but Python style rather than C/C++ style.

                                        S Offline
                                        S Offline
                                        senmx
                                        wrote on last edited by senmx
                                        #19

                                        @SGaist The config.log above is the log of build qt-opensource, not openssl.Myself OpenSSL build is arm binding.

                                        1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #20

                                          Can you provide the complete OpenSSL checks part ?

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          S 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved