PDA

View Full Version : How to use OpenSSL in subdirs project



Infinity
9th January 2014, 23:38
Hi,

I'm using a subdirs project to build my project together with some required libraries like ChrisW67 suggested in this thread:
http://www.qtcentre.org/threads/57402-How-to-determine-target-architecture-in-qmake-project-file

Now I also need to use OpenSSL (lcrypto).
On Linux I just installed the OpenSSL package provided by the distribution.

My problem is related to Windows. There I built OpenSSL on my own with mingw. If I want to use it in my project I have the same problem as I described in this post of the last thread:
http://www.qtcentre.org/threads/57402-How-to-determine-target-architecture-in-qmake-project-file?p=256409#post256409

I can't use the same solution with the subdirs project since OpenSSL is no qmake-project (at least I think it is not possible, correct me if I'm wrong!).
To work around the problem I tried to copy the OpenSSL libraries (*.dll and *.a files) in the corresponding system directories (System32 for 64-bit version and SysWOW64 for 32-bit version) hoping the linker is able to find them there. It isn't.
I noticed that ChrisW67 added a solution for determining the target architecture on Windows in the old thread, but I think the best solution would still be to put the libraries in appropriate system directories that the linker will find them and will use the right version (32-/64-bit).
So the question is, where do I have to install the libraries (especially the *.a files) on Windows that the linker is able to find them?

Thanks for helping.

ChrisW67
10th January 2014, 08:52
You leave the OpenSSL libraries where they were and you tell the project that needs to use them where to find them. Something like:


INCLUDEPATH += C:/OpenSSL/include
LIBS += -LC:/OpenSSL/lib -lcrypt

In the relevant PRO file.

In the IDE project settings add the C:/OpenSSL/bin directory (the one with the Dll files) to the run time PATH.
You may need to adjust the paths to suit where you have things.

Infinity
10th January 2014, 23:32
I have been using the suggested solution - providing the full location in the pro file - yet.
The problem is that I have to distinguish between the 64-bit and the 32-bit versions then. To avoid that I was using the subdirs project (according to ChrisW67 suggestion in the last thread) which works very well for my own libraries.

I think there is no other way then using the code to determine the target architecture he added later in the last thread (I'm using the Linux version on Windows because I'm using MinGW instead of msvc):


win32 {
win32-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
win32-g++-32:QMAKE_TARGET.arch = x86
win32-g++-64:QMAKE_TARGET.arch = x86_64
contains(QMAKE_TARGET.arch, x86_64):{
LIBS += -L../../openssl-mingw_amd64/lib/ -lcrypto
} else {
LIBS += -L../../openssl-mingw_i386/lib/ -lcrypto
}
} else
# ...

Of course this works, but now I'm needing the target architecture again which ChrisW67 advised me to avoid (that's why I was asking for a global place to install the libs like it is possible on Linux).
I think the problem is solved, but if there's a better solution I'm still interested.