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. Trying to link OpenSSL libraries under Windows

Trying to link OpenSSL libraries under Windows

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 23.8k 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.
  • M Offline
    M Offline
    m6a-uds
    wrote on 18 Mar 2013, 17:29 last edited by
    #1

    Hello!

    I am making a project which requires both Windows and Linux compilation. It worked fine until I tried to include OpenSSL functions. I have been stuck for days on that issue and I can't seem to be able to find a solution.

    On Linux, everything works fine (I yum-installed openssl-devel and crypto-devel). I just needed to add
    @LIBS += -lcrypto -lssl@

    On Windows, I installed OpenSSL (Both in system path and "C:\OpenSSL-Win32")
    I added
    @INCLUDEPATH += C:\OpenSSL-Win32\include@
    which seems to work fon linking headers.

    with
    @LIBS += -lcrypto -lssl@
    I get
    @:-1: error: cannot find -lcrypto@

    with
    @LIBS += -LC:\OpenSSL-Win32\lib@
    I get
    @documentmanager.cpp:21: error: undefined reference to `AES_set_encrypt_key'@

    I tried a combinaison of both:
    @LIBS += -L"C:\OpenSSL-Win32" -lcrypto -lssl@
    And I get
    @:-1: error: cannot find -lcrypto@

    Can anyone help me?

    EDIT: Qt creator is installed with the Qt 5.0.1 and MingW version

    Thank you!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 18 Mar 2013, 21:14 last edited by
      #2

      Hi,

      The right path is indeed "C:/OpenSSL-Win32/lib" (better with / even on windows)
      AES_set_encrypt_key missing means that there might be something not right with your installed OpenSSL. Which version did you install ? And do you compile you application as 32bit ?

      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
      0
      • M Offline
        M Offline
        m6a-uds
        wrote on 18 Mar 2013, 21:54 last edited by
        #3

        Hello!

        Thank you for your answer. Now my LIBS line is this:
        @LIBS += -L"C:/OpenSSL-Win32/lib" -lssl -lcrypto"@
        but I still get
        @:-1: error: cannot find -lssl
        :-1: error: cannot find -lcrypto
        collect2.exe:-1: error: error: ld returned 1 exit status@

        And if I remove -lssl and -lcrypto
        @LIBS += -L"C:/OpenSSL-Win32/lib"@
        then I get
        @C:\Users\Max\Prog\ift_6001-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug\debug\documentmanager.o:-1: In function ZN15DocumentManagerC2EP5QFile': C:\Users\Max\Prog\CryptoSh\Document\documentmanager.cpp:21: error: undefined reference to AES_set_encrypt_key'
        ...
        collect2.exe:-1: error: error: ld returned 1 exit status@

        I installed OpenSSL with the installer here: http://slproweb.com/products/Win32OpenSSL.html

        The project is configured for 32bits. (But I also installed the 64bits OpenSSL just in case.)

        Would it help to recompile the whole Qt Framework with openssl support, or it is not relevant to my case?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 18 Mar 2013, 22:17 last edited by
          #4

          I don't have my Windows machine at hand to check. Can you verify the name of the libs ?
          And if i'm not mistaken you might have to also link to libeay32 (LIBS += -llibeay32)

          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
          0
          • M Offline
            M Offline
            m6a-uds
            wrote on 18 Mar 2013, 23:04 last edited by
            #5

            Thank you so much!

            It works now! The answer was:

            @LIBS += -L"C:/OpenSSL-Win32/lib" -llibeay32@

            Thanks again!

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 19 Mar 2013, 21:27 last edited by
              #6

              Your welcome !

              Don't forget to update the thread subject to solved

              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
              0
              • Q Offline
                Q Offline
                Qu0ll
                wrote on 20 Jul 2013, 02:26 last edited by
                #7

                I am having an issue with this as well.

                I am trying to display Google Maps within a Qt 5.1 WebView but nothing displays and I received this message on the console:

                Unable to init SSL Context:

                I was told I needed to link with OpenSSL so I followed the instructions in this thread but I still reveive the same error above.

                I am not getting any compile or link errors so what else might I have to do to get HTTPS (which requires SSL) to work?

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  TheFox
                  wrote on 20 Jul 2013, 09:53 last edited by
                  #8

                  Are you linking ssleay32 too?

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    Qu0ll
                    wrote on 20 Jul 2013, 20:18 last edited by
                    #9

                    I have it working now. The problem seemed to be the way I installed OpenSSL. Initially I chose the option to install the DLLs into a subdirectory of where I installed OpenSSL but this option didn't work. When I reinstalled OpenSSL and chose the other option to have them installed into the Windows System directory I was able to get SSL happening and the Google Maps application started working.

                    I am concerned about this. It is important to me that I am able to ship my Qt application with everything it needs to run on each environment. I do not wish to have my users have to install OpenSSL into their Windows System folder for my application to run successfully.

                    Is there a way to use OpenSSL in a Qt application on Windows without forcing the end user to install OpenSSL? Would my first approach have worked if I had somehow referenced the OpenSSL binaries in the Qt project?

                    1 Reply Last reply
                    0
                    • JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote on 21 Jul 2013, 02:00 last edited by
                      #10

                      [quote author="Qu0ll" date="1374351495"]Initially I chose the option to install the DLLs into a subdirectory of where I installed OpenSSL but this option didn't work. When I reinstalled OpenSSL and chose the other option to have them installed into the Windows System directory I was able to get SSL happening and the Google Maps application started working.[/quote]It sounds like simply a case of your application being unable to find DLLs. When you installed them to the Windows System folder, that worked because ALL Windows apps look there. However, this method is a relic from Windows 98 times and is frowned upon now for security reasons -- only Windows should mess with the Windows folders; user apps should put their files elsewhere and (maybe) modify the PATH variable.

                      [quote]I am concerned about this. It is important to me that I am able to ship my Qt application with everything it needs to run on each environment. I do not wish to have my users have to install OpenSSL into their Windows System folder for my application to run successfully.

                      Is there a way to use OpenSSL in a Qt application on Windows without forcing the end user to install OpenSSL? Would my first approach have worked if I had somehow referenced the OpenSSL binaries in the Qt project?[/quote]The traditional method for deploying applications on Windows is simply to bundle all required DLLs with the program. This includes the Qt DLLs. See "this page":http://qt-project.org/doc/qt-5.1/qtdoc/deployment-windows.html for more info.

                      However, keep in mind that the Qt Project did not bundle OpenSSL for a reason. Please check if there are any "legal implications":http://security.stackexchange.com/questions/3378/is-strong-cryptography-legal-across-the-internet if you distribute it.

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      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