Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Linking against Openssl 1.1.2-dev Libs
QtWS25 Last Chance

Linking against Openssl 1.1.2-dev Libs

Scheduled Pinned Locked Moved Solved General and Desktop
openssllibrabrieslinkinglibrary
13 Posts 3 Posters 3.7k Views
  • 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.
  • O Offline
    O Offline
    Opa114
    wrote on 2 Dec 2018, 16:57 last edited by Opa114 12 Feb 2018, 18:00
    #1

    Hi there,

    i want to use Openssl 1.1.2-dev inside my QT-Project. Therefore i added the following lines to the Project File:

    win32: LIBS += -L$$PWD/../openssl/openssl/ -llibcrypto
    win32: LIBS += -L$$PWD/../openssl/openssl/ -llibssl
    INCLUDEPATH += $$PWD/../openssl/openssl/include
    DEPENDPATH += $$PWD/../openssl/openssl/include
    

    The Folders should be correct.

    So inside the main.cpp i included one openssl header:

    #include "openssl/x509.h"
    

    and added some example code - just for testing without real data:

    d2i_X509(nullptr, nullptr, 0);
    

    Then i run the code (Debug Version) and i got the error:

    main.cpp:14: Error: undefined reference to `d2i_X509'
    

    So what is the problem? Is my linking correct? Or did is miss something? Don't know where is the problem because i did it this way with an older version of Openssl (1.0.1) - the only difference are the lib names in the old version: libeay32 lssleay32.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 2 Dec 2018, 17:56 last edited by
      #2

      @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

      -llibssl.dll

      Afaik you can't link directly against a dll but need an import lib. There must be a 'libssl.a' somehwere around which you have to link to with '-lssl'. The same goes for libcrypto.dll

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      O A 2 Replies Last reply 2 Dec 2018, 18:01
      2
      • C Christian Ehrlicher
        2 Dec 2018, 17:56

        @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

        -llibssl.dll

        Afaik you can't link directly against a dll but need an import lib. There must be a 'libssl.a' somehwere around which you have to link to with '-lssl'. The same goes for libcrypto.dll

        O Offline
        O Offline
        Opa114
        wrote on 2 Dec 2018, 18:01 last edited by
        #3

        @Christian-Ehrlicher
        sorry my mistake - i copied some old stuff. i removed the *.dll ending.
        Inside the folder: L$$PWD/../openssl/openssl/ there is a licrypto.a and libcrypto.dll.a, same for the ssl lib.

        1 Reply Last reply
        0
        • C Christian Ehrlicher
          2 Dec 2018, 17:56

          @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

          -llibssl.dll

          Afaik you can't link directly against a dll but need an import lib. There must be a 'libssl.a' somehwere around which you have to link to with '-lssl'. The same goes for libcrypto.dll

          A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 2 Dec 2018, 18:02 last edited by aha_1980 12 Feb 2018, 18:03
          #4

          Hi @Opa114,

          Just to add to @Christian-Ehrlicher,

          There must be a 'libssl.a' somehwere around

          Or, depending on compiler, its named libssl.lib.

          So the linker call should look like this:
          win32: LIBS += -L$$PWD/../openssl/openssl/ -lcrypto -lssl

          Also, make sure OpenSSL was build with the same compiler you are using for your Qt project.

          Regards

          Qt has to stay free or it will die.

          O 1 Reply Last reply 2 Dec 2018, 18:11
          0
          • A aha_1980
            2 Dec 2018, 18:02

            Hi @Opa114,

            Just to add to @Christian-Ehrlicher,

            There must be a 'libssl.a' somehwere around

            Or, depending on compiler, its named libssl.lib.

            So the linker call should look like this:
            win32: LIBS += -L$$PWD/../openssl/openssl/ -lcrypto -lssl

            Also, make sure OpenSSL was build with the same compiler you are using for your Qt project.

            Regards

            O Offline
            O Offline
            Opa114
            wrote on 2 Dec 2018, 18:11 last edited by
            #5

            @aha_1980 said in Linking against Openssl 1.1.2-dev Libs:

            Hi @Opa114,

            Just to add to @Christian-Ehrlicher,

            There must be a 'libssl.a' somehwere around

            Or, depending on compiler, its named libssl.lib.

            So the linker call should look like this:
            win32: LIBS += -L$$PWD/../openssl/openssl/ -lcrypto -lssl

            Also, make sure OpenSSL was build with the same compiler you are using for your Qt project.

            Regards

            when i try it with -lcrypto and -lssl then i got this error:

            skipping incompatible C:\Users\Matth\Desktop\openssl\openssl/libcrypto.a when searching for -lcrypto
            skipping incompatible C:\Users\Matth\Desktop\openssl\openssl/libcrypto.dll.a when searching for -lcrypto
            cannot find -lcrypto
            

            same for the ssl library.

            A 1 Reply Last reply 2 Dec 2018, 18:14
            0
            • O Opa114
              2 Dec 2018, 18:11

              @aha_1980 said in Linking against Openssl 1.1.2-dev Libs:

              Hi @Opa114,

              Just to add to @Christian-Ehrlicher,

              There must be a 'libssl.a' somehwere around

              Or, depending on compiler, its named libssl.lib.

              So the linker call should look like this:
              win32: LIBS += -L$$PWD/../openssl/openssl/ -lcrypto -lssl

              Also, make sure OpenSSL was build with the same compiler you are using for your Qt project.

              Regards

              when i try it with -lcrypto and -lssl then i got this error:

              skipping incompatible C:\Users\Matth\Desktop\openssl\openssl/libcrypto.a when searching for -lcrypto
              skipping incompatible C:\Users\Matth\Desktop\openssl\openssl/libcrypto.dll.a when searching for -lcrypto
              cannot find -lcrypto
              

              same for the ssl library.

              A Offline
              A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on 2 Dec 2018, 18:14 last edited by
              #6

              @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

              skipping incompatible

              That is already a hint :)

              Again:

              • which compiler is used for OpenSSL and for your project?
              • are both 32bit resp. 64bit?

              Regards

              Qt has to stay free or it will die.

              O 1 Reply Last reply 2 Dec 2018, 18:21
              2
              • A aha_1980
                2 Dec 2018, 18:14

                @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

                skipping incompatible

                That is already a hint :)

                Again:

                • which compiler is used for OpenSSL and for your project?
                • are both 32bit resp. 64bit?

                Regards

                O Offline
                O Offline
                Opa114
                wrote on 2 Dec 2018, 18:21 last edited by
                #7

                @aha_1980
                For OpenSSL i used MinGW (this way and built it under Ubuntu: ./Configure mingw --cross-compile-prefix=i686-w64-mingw32- - prefix=/mnt/c/Users/Matth/Desktop/openssl/BUILD)

                And for my Project i used MinGW 64 (qmake: qmake.exe test.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" and Make: mingw32-make.exe -j4 in C:\Users\Matth\Desktop\build-test-Desktop_Qt_5_12_0_MinGW_64_bit-Debug)

                But both should be 32bit builds i think.

                A 1 Reply Last reply 2 Dec 2018, 18:26
                0
                • O Opa114
                  2 Dec 2018, 18:21

                  @aha_1980
                  For OpenSSL i used MinGW (this way and built it under Ubuntu: ./Configure mingw --cross-compile-prefix=i686-w64-mingw32- - prefix=/mnt/c/Users/Matth/Desktop/openssl/BUILD)

                  And for my Project i used MinGW 64 (qmake: qmake.exe test.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" and Make: mingw32-make.exe -j4 in C:\Users\Matth\Desktop\build-test-Desktop_Qt_5_12_0_MinGW_64_bit-Debug)

                  But both should be 32bit builds i think.

                  A Offline
                  A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 2 Dec 2018, 18:26 last edited by aha_1980 12 Feb 2018, 18:39
                  #8

                  @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

                  i686-w64-mingw32

                  Are you sure this means 32 bit?

                  Edit: at least MinGW 64 is not 32bit ;)

                  Edit2: can you build OpenSSL on Windows with the MinGW64 compiler? Should avoid all possible incompatibilities :)

                  Qt has to stay free or it will die.

                  O 1 Reply Last reply 2 Dec 2018, 19:05
                  0
                  • A aha_1980
                    2 Dec 2018, 18:26

                    @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

                    i686-w64-mingw32

                    Are you sure this means 32 bit?

                    Edit: at least MinGW 64 is not 32bit ;)

                    Edit2: can you build OpenSSL on Windows with the MinGW64 compiler? Should avoid all possible incompatibilities :)

                    O Offline
                    O Offline
                    Opa114
                    wrote on 2 Dec 2018, 19:05 last edited by
                    #9

                    @aha_1980 said in Linking against Openssl 1.1.2-dev Libs:

                    Edit2: can you build OpenSSL on Windows with the MinGW64 compiler? Should avoid all possible incompatibilities :)

                    i could try it

                    O 1 Reply Last reply 2 Dec 2018, 20:21
                    0
                    • O Opa114
                      2 Dec 2018, 19:05

                      @aha_1980 said in Linking against Openssl 1.1.2-dev Libs:

                      Edit2: can you build OpenSSL on Windows with the MinGW64 compiler? Should avoid all possible incompatibilities :)

                      i could try it

                      O Offline
                      O Offline
                      Opa114
                      wrote on 2 Dec 2018, 20:21 last edited by
                      #10

                      @Opa114
                      instead of building openssl under windows i run it again under ubuntu and did a cross compile but now with minGW 64bit which creates a 64-bit dll. With these it works. but should a 64bit application able to use 32bit dlls? Or i am wrong?

                      A 1 Reply Last reply 2 Dec 2018, 20:25
                      0
                      • O Opa114
                        2 Dec 2018, 20:21

                        @Opa114
                        instead of building openssl under windows i run it again under ubuntu and did a cross compile but now with minGW 64bit which creates a 64-bit dll. With these it works. but should a 64bit application able to use 32bit dlls? Or i am wrong?

                        A Offline
                        A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on 2 Dec 2018, 20:25 last edited by
                        #11

                        @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

                        But should a 64bit application able to use 32bit dlls? Or i am wrong?

                        Sorry, but yes you are. You cannot mix these.

                        Regards

                        Qt has to stay free or it will die.

                        O 1 Reply Last reply 3 Dec 2018, 09:18
                        3
                        • A aha_1980
                          2 Dec 2018, 20:25

                          @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

                          But should a 64bit application able to use 32bit dlls? Or i am wrong?

                          Sorry, but yes you are. You cannot mix these.

                          Regards

                          O Offline
                          O Offline
                          Opa114
                          wrote on 3 Dec 2018, 09:18 last edited by
                          #12

                          @aha_1980 said in Linking against Openssl 1.1.2-dev Libs:

                          @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

                          But should a 64bit application able to use 32bit dlls? Or i am wrong?

                          Sorry, but yes you are. You cannot mix these.

                          Regards

                          okay thanks for clarification. So it was my mistake because i thought i can mix it. I know the other way would not work.

                          A 1 Reply Last reply 3 Dec 2018, 09:19
                          1
                          • O Opa114
                            3 Dec 2018, 09:18

                            @aha_1980 said in Linking against Openssl 1.1.2-dev Libs:

                            @Opa114 said in Linking against Openssl 1.1.2-dev Libs:

                            But should a 64bit application able to use 32bit dlls? Or i am wrong?

                            Sorry, but yes you are. You cannot mix these.

                            Regards

                            okay thanks for clarification. So it was my mistake because i thought i can mix it. I know the other way would not work.

                            A Offline
                            A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote on 3 Dec 2018, 09:19 last edited by
                            #13

                            @Opa114 Thanks for the feedback. So please mark this topic as SOLVED now.

                            Qt has to stay free or it will die.

                            1 Reply Last reply
                            0

                            5/13

                            2 Dec 2018, 18:11

                            topic:navigator.unread, 8
                            • Login

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