PDA

View Full Version : Qt 4.5.3 openssl 0.9.8k windows static mingw32



tpf80
6th November 2009, 20:21
Thank you in advance for your assistance. I am not quite sure if this is an issue with openssl or with my Qt configuration.

I built openssl using the following command from the openssl directory:



ms/mingw32


This worked fine, and the test came out ok.

I then built Qt static using the following command:



configure -release -opensource -static -openssl-linked -I "D:/openssl-0.9.8k/outinc"
-L "D:/openssl-0.9.8k/out" -webkit -nomake examples -nomake demos
-no-qt3support -no-style-plastique -no-style-cleanlooks -no-style-motif -no-style-cde
-no-style-windowsce -no-style-windowsmobile -platform win32-g++


This process was successful.

I then tried to compile an application that I had working in an older version of Qt4, but was using shared libraries in the old build.

The result was this error:


mingw32\bin\ld.exe: cannot find -Lssleay32


I checked my openssl 0.9.8K build, and there is no such file in the out folder, however my old environment had such a file. When I copied libssleay32.a from my old build environment to the D:\openssl-0.9.8k\out folder, and I renamed "libeay32.a" to "liblibeay32.a" then my program would build however there are still the following 2 issues:

1) the libeay32.a that I used was from an older version of openssl from 2007. This could in theory cause problems, and I would like to be able to use the latest version if possible (however the latest version does not contain this file).

2) the compiled program asks for "libeay32.dll" rather than that functionality being statically compiled into the program.

Here also is my .pro file in case there is something within that is wrong.


#########################
# Custom for automatic updater
#########################

TEMPLATE = app
unix: TARGET = release_linux/updater
win32: TARGET = release_windows/updater
DEPENDPATH += maingui ssl fab_varlib
INCLUDEPATH += maingui ssl fab_varlib

win32 {
LIBS += -L D:/openssl-0.9.8k/out
}

# Input
HEADERS += maingui/calculatorform.h maingui/dialog_login.h \
ssl/client.h ssl/dialog_common.h \
fab_varlib/fab_var.h

FORMS += maingui/calculatorform.ui maingui/dialog_login.ui

SOURCES += maingui/calculatorform.cpp maingui/dialog_login.cpp \
maingui/main.cpp \
ssl/client.cpp ssl/dialog_common.cpp

QT += core \
gui \
sql \
network
CONFIG += static

tpf80
9th November 2009, 04:37
after a bit of toiling and experimentation I finally fixed the issue. here is how I solved it in case someone else had the same problem, or in case someone else has a better suggestion to fix it:

1) I copied libcrypto.a and libssl.a to my <qtdir>\lib
2) i copied the openssl directory from outinc to <qtdir>\include

3) I noticed that the OPENSSL_LIBS option would not work. It would always error out if I added this option to the configure command when reconfiguring Qt. Upon further investigation, I found that this line was hard coded in <qtdir>\tools\configure\configureapp.cpp:



\\line 2400
else if (dictionary[ "OPENSSL" ] == "linked")
qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32");


I changed it to this:



\\line 2400
else if (dictionary[ "OPENSSL" ] == "linked")
qmakeVars += QString("OPENSSL_LIBS = -lssl -lcrypto");


I then ran the command to configure Qt for what I needed:


configure -release -opensource -static -openssl-linked -webkit
-nomake examples -nomake demos -no-qt3support
-no-style-plastique -no-style-cleanlooks -no-style-motif
-no-style-cde -no-style-windowsce -no-style-windowsmobile
-no-phonon -no-dsp -no-vcproj -no-incredibuild-xge
-no-opengl -no-scripttools -no-sql-sqlite -platform win32-g++


and then:


make sub-src


After this was done, I was able to compile my apps like normal with Qt and openssl static as long as I followed the following steps:

1: run qmake
2: go in the make file it generates and alter the "Libs =" entry by changing
"-lssleay32 -llibeay32" to "-lssl -lcrypto" . Also it is a must that -lgdi32 is moved
to be after "-lssl -lcrypto" in the list.
3: run make, and everything works as it should, the only DLL needed now is mingwm10.dll


My only questions now are:
Is there a way to achieve this without editing configureapp.cpp?
Is there a way for qmake to put the "-lssl -lcrypto" by itself instead of "-lssleay32 -llibeay32" (and making sure that gdi32 is after them)?

manekineko
26th February 2010, 02:59
I don't know if you'll see this, but if you do, I'm trying to do the same thing as you, and really having some terrible difficulty.
http://www.qtcentre.org/threads/25453-Qt-4-5-3-openssl-0-9-8k-windows-static-mingw32?highlight=Qt+4.5.3+openssl+0.9.8k+windows+ static+mingw32

What made you decide to modify the files that QT looks for instead of just renaming your files like you did for the old build?
Also, why did you say that lgdi32 must be after?

I've only managed to get a successful compile of QT when using a pre-built version of OpenSSL, but that one unfortunately is acting like your first post and requiring external dll's for compiled programs.
When I compiled OpenSSL using Cygwin configured to compile for mingw, it's erroring out during QT compile.
When I try to compile OpenSSL it's not working, and I'm getting tons of errors.

tpf80
26th February 2010, 05:44
The reason I had to change the files that Qt looks for, is that the static openssl libraries are named different. The static ones are actually libssl and libcrypto. The configureapp.cpp file was hard coded to use the dynamic library.

As for the reason I had to change the order for -lgdi32 to be after -lssl -lcrypto, it is because openssl has gdi32 as one of its dependencies.