serge_girard wrote: ↑Tue Nov 26, 2024 10:33 am
Edward,
First compilation give this error:
Code: Select all
P:/hmg.3.6/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lssl: No such file or directory
P:/hmg.3.6/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcrypto: No such file or directory
I have this in my HBC-file:
Code: Select all
libs=hbssl
libs=libeay32
libs=ssleay32
I suppose C:\hmg.3.6\hmg64.hbc (P:\hmg.3.6\hmg64.hbc in my case) need some adjustments?
Serge
Hi Serge.
There are no SSL libraries, so we have to build them. We proceed in a similar way as with hbmysql.
Preparing OpenSSL v.3:
Download the
Win64 OpenSSL v3.4.0 EXE installer ( 64-bit! ) from the website
https://slproweb.com/products/Win32OpenSSL.html
Run the downloaded installer and install OpenSSL to the
C:\OpenSSL-Win64-3.4.0 folder, when asked where to copy the OpenSSL DLLS indicate "The OpenSSL binaries (/bin) directory"
Building the hbssl library:
As with the missing hbmysql, we need to have the harbour sources. The
hbssl sources are located in the
core-master\contrib\hbssl\ folder. Copy the
hbssl folder to
c:\hmg.3.6\harbour64\contrib\ (in your case it would be
P:\hmg.3.6\harbour64\contrib\ )
In the copied folder, create a batch file
build_hbssl.bat
Code: Select all
@echo off
SET backup=%path%
SET HB_WITH_OPENSSL=C:\OpenSSL-Win64-3.4.0\include
SET HMGPATH=c:\hmg.3.6
SET PATH=%HMGPATH%\harbour64\bin;%HMGPATH%\mingw64\bin;%PATH%
hbmk2 hbssl.hbp -i%hmgpath%\include
ROBOCOPY .\ %HMGPATH%\HARBOUR64\lib\win\mingw64\ *.a
set path=%backup%
set backup=
pause
* in the HMGPATH variable we define the path where our HMG 3.6 is installed (in your case it would be
P:\hmg.3.6)
* in the HB_WITH_OPENSSL variable we define the path where OpenSSL 3 is installed
Modification of hbssl.hbc for OpenSSL 3 library:
In OpenSSL 3 the names of the library files have changed, so you need to edit the file
c:\hmg.3.6\harbour64\contrib\hbssl.hbc to the following notations:
Code: Select all
description=OpenSSL wrapper (encryption)
# NOTE: use HB_STATIC_OPENSSL=yes envvar to link openssl lib statically
incpaths=.
headers=${hb_name}.ch
skip={dos}
{!HB_DYNBIND_OPENSSL&!(HB_STATIC_OPENSSL&!hbdyn)}libs=${_HB_DYNPREF}${hb_name}${_HB_DYNSUFF}
{!HB_DYNBIND_OPENSSL& (HB_STATIC_OPENSSL&!hbdyn)}libs=${_HB_DYNPREF}${hb_name}s${_HB_DYNSUFF}
{!HB_DYNBIND_OPENSSL&unix}libs=ssl crypto
{!HB_DYNBIND_OPENSSL&os2}libs=libssl_s libcrypto_s
{!HB_DYNBIND_OPENSSL&!(HB_STATIC_OPENSSL&!hbdyn)&win&!allmingw}libs=ssleay32 libeay32
{!HB_DYNBIND_OPENSSL& (HB_STATIC_OPENSSL&!hbdyn)&win&!allmingw}libs=ssleay32 libeay32
#{!HB_DYNBIND_OPENSSL&!(HB_STATIC_OPENSSL&!hbdyn)&allmingw}libs=ssl crypto
#{!HB_DYNBIND_OPENSSL& (HB_STATIC_OPENSSL&!hbdyn)&allmingw}libs=ssl crypto
{!HB_DYNBIND_OPENSSL&!(HB_STATIC_OPENSSL&!hbdyn)&allmingw}libs=libssl-3-x64 libcrypto-3-x64
{!HB_DYNBIND_OPENSSL& (HB_STATIC_OPENSSL&!hbdyn)&allmingw}libs=libssl-3-x64 libcrypto-3-x64
{!HB_DYNBIND_OPENSSL& (HB_STATIC_OPENSSL&!hbdyn)&allwin}libs=crypt32
We build the hbssl library by running the
build_hbssl.bat file.
That's all.
In this version of hbssl with OpenSSL 3, no external .dll libraries are required, because they are imported into the liblibcrypto-3-x64.a and liblibssl-3-x64.a libraries, so they will be included in the application executable
If you compile using an IDE, put the following in the configuration:
Code: Select all
libs=hbssl
libs=libssl-3-x64
libs=libcrypto-3-x64
or simpler, it is enough to do the following:
(must be .hbc extension)
If you compile using a build64.bat, add the following to .hbp file in your project: