Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Can't get OpenSSL to run on Windows (same code works fine on Linux)
Forum Updated to NodeBB v4.3 + New Features

Can't get OpenSSL to run on Windows (same code works fine on Linux)

Scheduled Pinned Locked Moved Installation and Deployment
23 Posts 3 Posters 10.3k Views 1 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.
  • R Offline
    R Offline
    rwtmoorehotmail.com
    wrote on last edited by
    #1

    I recently wrote a desktop app for Linux(VirtualBox) that employs openSSL. I’m just using the libraries for encrypting and decrypting files (no network) and it works great. Now, I’m trying to create a Windows version and it’s one of the most frustrating things I’ve ever done.

    So far, the online community hasn’t been much help (dozens of proposed solutions, all completely different, and none of them work for me).

    Specifics:

    I have a 64-bit machine.
    I'm using Qt Creator as my IDE and mingw as my compiler (x86_64-w64-mingw32-gcc.exe).
    I've downloaded and installed Win64 OpenSSL v1.0.1g from http://slproweb.com/products/Win32OpenSSL.html
    The build and run paths have C:\OpenSSL-Win64\include\openssl;C:\OpenSSL-Win64\bin;C:\OpenSSL-Win64\lib
    In the .pro file I have:
    HEADERS += openssl/opensslconf.h openssl/evp
    LIBS += -L"C:/OpenSSL-Win64/lib" -llibeay32
    CONFIG+= configure.exe -openssl-linked OPENSSL_LIBS="-llibssl -llibcrypto -lgdi64" -l ws2_64 -l advapi64 -l gdi64 -l user64 -l crypt64 -I -static -no-exceptions
    QMAKE_LFLAGS += -static -static-libgcc -static-libstdc++ -openssl-linked

    The app compiles and runs, but when I get to this line:

        @EVP_EncryptInit(&ctxE, EVP_aes_256_cbc(), constKey, constIv);@
    

    It crashes with a segmentation fault.

    If I use this line before the above (as suggested by another coder), I get the same segmentation fault:

        @EVP_CIPHER_CTX_init(&ctxD);@
    

    So, it has noting to do with the key or iv. It's like the app can see the header but not the code. I have tried many, many suggested solutions with no progress.

    Any help would be greatly appreciated.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      I think you need to compile Qt itself with your OpenSSL first, then you can start using it in your apps.

      (Z(:^

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rwtmoorehotmail.com
        wrote on last edited by
        #3

        Thanks for the response. How do I do that?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Asking uncle Google is always a good idea ;) "Link":http://qt-project.org/wiki/Compiling-OpenSSL-with-MinGW.

          (Z(:^

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rwtmoorehotmail.com
            wrote on last edited by
            #5

            Thanks for the reply.

            The reason I ask is because I'm not sure what "compiling Qt itself with your OpenSSL" means. I downloaded OpenSSL and ran the executable which set up the directory structure for it. Then, I added the libraries and paths to my project. I thought that when I compiled my project in Qt Creator, everything I need would be compiled in the app or know where to get it.

            The link you gave me instructs me on how to install OpenSSL on Linux. I already have it working on Linux.

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              That link is for Windows...

              OK, then see "this thread":http://qt-project.org/forums/viewthread/26029.

              I am sure there was a good tutorial on this somewhere, but I am not able to find it at the moment.

              (Z(:^

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rwtmoorehotmail.com
                wrote on last edited by
                #7

                export and ./Configure looked like Linux commands to me. Both gave me an error: "is not recognized as an internal or external command, operable program or batch file" from the Windows command prompt.

                The instructions in the link looked to me to do what I have already done - download and install OpenSSL and set up the paths.

                I tried running the Configure script, but I don't have an msys directory. I downloaded msys (MSYS-1.0.11.exe) and the installation told me I already had "Minimal SYStem installed". I don't know where it is. I did a search for Configure on my entire system and nothing came up.

                This is not a trivial problem. I've been at this a long time and have done extensive web searches with no solution.

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

                  Hi,

                  Which version of Qt are you trying to build ? With what compiler ?

                  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
                  • R Offline
                    R Offline
                    rwtmoorehotmail.com
                    wrote on last edited by
                    #9

                    Hi.

                    I'm using Qt 5.1.1 and this is my compiler: x86_64-w64-mingw32-gcc.exe. I also set it up using Microsoft Visual C++ Compiler 11.0(amd64), which compiles and runs and gives me the same segmentation fault as described above.

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

                      Just to be sure we are on the same line: you are going to build Qt with openssl ? Correct ?

                      If so, you should consider getting the latest sources first. Then decide where you are going to use MinGW or VS to do that

                      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
                      • R Offline
                        R Offline
                        rwtmoorehotmail.com
                        wrote on last edited by
                        #11

                        I already built this app for Linux and it's been working great for months. I use the OpenSSL libraries only for encryption/decryption. I created a .pro file for the Windows version, which has all the Windows config, paths, etc. But, it uses the same source files.

                        The latest Qt version is 5.2.1 which is only one rev from what I'm using. The reason I chose 5.1.1 was because that what the Linux app was built from.

                        It's just not seeing the compiled code for OpenSSL.

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

                          Oh wait, I might have misunderstood you. Are you calling OpenSSL functions directly in your code ?

                          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
                          • sierdzioS Offline
                            sierdzioS Offline
                            sierdzio
                            Moderators
                            wrote on last edited by
                            #13

                            [quote author="SGaist" date="1398287845"]Oh wait, I might have misunderstood you. Are you calling OpenSSL functions directly in your code ?[/quote]

                            AFAIK he is, see the initial post.

                            (Z(:^

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

                              [quote author="sierdzio" date="1398322738"][quote author="SGaist" date="1398287845"]Oh wait, I might have misunderstood you. Are you calling OpenSSL functions directly in your code ?[/quote]

                              AFAIK he is, see the initial post.[/quote]

                              Indeed, then the most likely problem is that the downloaded OpenSSL wasn't built with MinGW 64

                              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
                              • R Offline
                                R Offline
                                rwtmoorehotmail.com
                                wrote on last edited by
                                #15

                                @SGaist Thanks for the reply. I got OpenSSL from http://slproweb.com/products/Win32OpenSSL.html. It doesn't say what was used to build it, but I'm assuming it wasn't mingw.

                                So, I downloaded a mingw64 build of OpenSSL from http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.0/64-bit/.

                                The first problem is that there is no libeay.dll in this distribution and my app won't compile without it. I don't know where to get it or where it goes; there is no lib directory in my new OpenSSL directory, which is where libeay.dll usually lives.

                                Secondly, when I try to run the following perl script in the MINGW32:~ shell

                                perl Configure mingw -no-share -no-asm --prefix=/C/openssl-1.0.1g

                                I get the error "Can't open perl script "Configure": No such file or directory.

                                I found some folks online with the same error as above, but their solutions didn't apply or didn't work for me.

                                1 Reply Last reply
                                0
                                • R Offline
                                  R Offline
                                  rwtmoorehotmail.com
                                  wrote on last edited by
                                  #16

                                  I thought I could just include the new OpenSSL in my qt app and let Qt Creator compile the SSL stuff, but without libeay.dll, I'm dead in the water.

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

                                    Is it a static 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
                                    0
                                    • R Offline
                                      R Offline
                                      rwtmoorehotmail.com
                                      wrote on last edited by
                                      #18

                                      I want it to be, otherwise I'd have to install OpenSSL on all the machines it will run on. At this point, I'd be happy with any build that works.

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

                                        You wouldn't need to install OpenSSL on every machine, just deploy the dlls with your application.

                                        Just stumble upon "this":http://qt-project.org/wiki/Compiling-OpenSSL-with-MinGW might help

                                        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
                                        • R Offline
                                          R Offline
                                          rwtmoorehotmail.com
                                          wrote on last edited by
                                          #20

                                          Yeah, I've looked at that page many times. sierdzio included that link in this forum earlier. I cannot get those scripts to run (see previous posts).

                                          I also tried running them in a mingw32:~ shell unsuccessfully (error = "Can't open perl script "Configure": No such file or directory). I also tried configure and ./configure and ./Configure, no dice.

                                          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