Lazarus

Programming => Networking and Web Programming => Topic started by: senglit on June 22, 2020, 07:54:56 am

Title: [CLOSED] Fail to load ssleay32.dll libssl32.dll
Post by: senglit on June 22, 2020, 07:54:56 am
Hi, all

I openned a topic to ask question about lnet. But later I found I asked a wrong question. So, I closed that topic and ask the right question here.

After I upgrade lazarus from 2.0.6 to 2.0.8 and fpc3.2.0 as well, my lnet does not work. After a lot of trying I found the problem come from unit openssl.pas in fpc3.2.0

Code: Pascal  [Select][+][-]
  1. var
  2.   {$IFDEF WINDOWS}
  3.   DLLSSLName: string = 'ssleay32.dll';
  4.   DLLSSLName2: string = 'libssl32.dll';
  5.   DLLUtilName: string = 'libeay32.dll';
  6.  
  7. Function LoadLibraries : Boolean;
  8. begin
  9.   Result:=False;
  10. {$IFDEF DARWIN}  
  11.   // Mac OS no longer allows you to load the unversioned one. Bug ID 36484.
  12.   DLLVERSIONS[1]:=DLLVERSIONS[2];
  13. {$ENDIF}
  14.   SSLUtilHandle := LoadLib(DLLUtilName);
  15.   SSLLibHandle := LoadLib(DLLSSLName);
  16.   {$IFDEF MSWINDOWS}
  17.   if (SSLLibHandle = 0) then
  18.     SSLLibHandle := LoadLib(DLLSSLName2);
  19.   {$ELSE MSWINDOWS}
  20.    {$IFDEF OS2}
  21.   if (SSLUtilHandle = 0) then
  22.     SSLUtilHandle := LoadLib(DLLUtilName2);
  23.   if (SSLLibHandle = 0) then
  24.     SSLLibHandle := LoadLib(DLLSSLName2);
  25.    {$ENDIF OS2}
  26.   {$ENDIF MSWINDOWS}
  27.   Result:=(SSLLibHandle<>0) and (SSLUtilHandle<>0);
  28. end;      
  29.  

I got both SSLLibHandle and SSLUtilHandle resulted in 0 which means these dlls are not loaded. But I have already installed Win64 OpenSSL v1.0.2 (I tried v1.1.1, too) and I check these 3 dlls are all in c:\windows\system32.

Why did lnet failed to load these dlls? Is it possible that it happened because openssh is installed together with lazarus and it made some change?
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: senglit on June 22, 2020, 08:24:14 am
I think there is a possible reason:

I installed Lazarus 2.0.8 64bit in win10 64bit and my openssl is 64bit, too. FPC3.2.0 does not have a 64 bit version, but only a 32-cross-64(also installed). if I set lazarus "config and target" to default, it will build a 32 or 64 program? I tried win32, win64, default, all do not work, dls can not be loaded.

I also tried openssl 32bit version, still can not be loaded.

Maybe I messed up with these 32/64 things?
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: TRon on June 22, 2020, 10:07:36 am
a) do you have c:\temp directory created ?
b) your configuration seems to suggest that you compile for 64 bit by default.

just get rid of the Lazarus/packages baggage and make a small and simple testing application.

If you have installed the FreePascal sources (is mandatory for Lazarus so you should have them) then there is a very small example inside openssl package (test1)

If you do not know what to do exactly:
1) create a <work> directory for testing purpose
2) copy <your fpc source location>/packages/openssl/src/*.* to <work>
3) copy <your fpc source location>/packages/openssl/examples/test1.pas to <work>
4) copy your ssl libraries to <work>
5) open a commandline, and navigate over to <work> directory
6) type "fpc -B test1.pas" (without quotes) and press enter.
7) run test1 by typing "test1" (without quotes) and press enter.
and last) paste the results back in this thread


edit: skip to post #5 for instructions (those are updated to be more in line with your current situation).
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: TRon on June 22, 2020, 10:44:03 am
FPC3.2.0 does not have a 64 bit version, but only a 32-cross-64(also installed).
What do you mean with "FPC 3.2.0  does not have 64-bit version" !?

Nonsense, as the readme tells us (https://sourceforge.net/projects/freepascal/files/)
Quote
                            Free Pascal Compiler

                               Version 3.2.0

****************************************************************************
* Introduction
****************************************************************************

Please also read the platform specific README file, if it exists.

This package contains an advanced freeware 32-bit/64-bit/16-bit pascal
compiler for several platforms. The language and the runtime library are
almost compatible with Turbo Pascal 7.0 and recent Delphi releases. There is
also partial support for the Macintosh pascal dialect.

News and changes related to this release are described in whatsnew.txt.

Free Pascal 3.2.0 is currently available for the following platforms:
- Linux-i386
- Linux-x86_64 (amd64)
- Linux-powerpc
- Linux-sparc
- Linux-ARM
- Win32-i386 (2000/XP, WinNT or later)
- Win64-x86_64 (XP or later)
- Wince-ARM (cross compiled from win32-i386)
- FreeBSD-i386
- FreeBSD-x86_64
- Mac OS X/Darwin for PowerPC (32 and 64 bit)
- Mac OS X/Darwin for Intel (32 and 64 bit)
- iOS (ARM and AArch64/ARM64) and iPhoneSimulator (32 and 64 bit)
- OS/2-i386 (OS/2 Warp v3.0, 4.0, WarpServer for e-Business and eComStation)
- Haiku-i386
- GO32v2-i386
- Nintendo Gameboy Advance-ARM (cross compile from win32-i386)
- Nintendo DS-ARM (cross compile from win32-i386)
- Nintendo Wii-powerpc (cross compile from win32-i386)
- AIX 5.3 and later for PowerPC (32 and 64 bit)
- Java JVM (1.5 and later) and Android Dalvik (Android 4.0 and later)
- Android (AArch64, x86_64, ARM, i386, MIPS) via cross-compiling.
- MSDos-i8086 (cross compiled from win32-i386 or Linux)
- Amiga, MorphOS and AROS

So, what's up with that ? (*)

edit (*) to clarify: yes i know/understand  that there isn't a win64 version available for download, it is suggested there is. Even more so on the new features and changes pages related to 3.2.0 (new features suggest necessity for new functionality and changes not mentioning non availability/lack of win64 native compiler).
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: PascalDragon on June 22, 2020, 12:06:19 pm
FPC3.2.0 does not have a 64 bit version, but only a 32-cross-64(also installed).
What do you mean with "FPC 3.2.0  does not have 64-bit version" !?

edit (*) to clarify: yes i know/understand  that there isn't a win64 version available for download, it is suggested there is. Even more so on the new features and changes pages related to 3.2.0 (new features suggest necessity for new functionality and changes not mentioning non availability/lack of win64 native compiler).

That is exactly what senglit meant: we don't provide a native Win64 compiler as download.
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: TRon on June 22, 2020, 01:08:27 pm
That is exactly what senglit meant: we don't provide a native Win64 compiler as download.
Ok, thank you Pascal Dragon.


@englit: In that case, the instructions are different and for testing purpose only.

- download and install FreePascal 3.2.0 32 bit for windows
- make sure you download and extract the free pascal 3.2.0 sources as well
- create a <work> directory for testing purpose
- copy <your FPC source location>/packages/openssl/src/*.* to <work>
- copy <your fpc source location>/packages/openssl/examples/test1.pas to <work>
- copy your 32-bit ssl libraries/dll's to <work>
- open a commandline, and navigate over to <work> directory
- type "fpc -B test1.pas" (without quotes) and press enter.
- run test1 by typing "test1" (without quotes) and press enter.
- paste returned results back into this thread for review
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: senglit on June 22, 2020, 02:13:58 pm

@englit: In that case, the instructions are different and for testing purpose only.

- download and install FreePascal 3.2.0 32 bit for windows
- make sure you download and extract the free pascal 3.2.0 sources as well
- create a <work> directory for testing purpose
- copy <your FPC source location>/packages/openssl/src/*.* to <work>
- copy <your fpc source location>/packages/openssl/examples/test1.pas to <work>
- copy your 32-bit ssl libraries/dll's to <work>
- open a commandline, and navigate over to <work> directory
- type "fpc -B test1.pas" (without quotes) and press enter.
- run test1 by typing "test1" (without quotes) and press enter.
- paste returned results back into this thread for review

C:\tmp>fpc -B test01
Free Pascal Compiler version 3.2.0 [2020/06/04] for i386
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test01.pp
Compiling oraclew.pp
Compiling oci.pp
Compiling oratypes.pp
oratypes.pp(300,12) Warning: Function result does not seem to be set
nzerror.inc(535,75) Note: Values in enumeration types have to be ascending
oro_implementation.inc(121,12) Warning: Function result does not seem to be set
oro_implementation.inc(129,12) Warning: Function result does not seem to be set
oro_implementation.inc(137,12) Warning: Function result does not seem to be set
oro_implementation.inc(145,12) Warning: Function result does not seem to be set
oro_implementation.inc(153,12) Warning: Function result does not seem to be set
oro_implementation.inc(161,12) Warning: Function result does not seem to be set
oro_implementation.inc(169,12) Warning: Function result does not seem to be set
oro_implementation.inc(177,12) Warning: Function result does not seem to be set
oro_implementation.inc(185,12) Warning: Function result does not seem to be set
oro_implementation.inc(193,12) Warning: Function result does not seem to be set
oro_implementation.inc(201,12) Warning: Function result does not seem to be set
oro_implementation.inc(209,12) Warning: Function result does not seem to be set
oro_implementation.inc(217,12) Warning: Function result does not seem to be set
oro_implementation.inc(225,12) Warning: Function result does not seem to be set
oro_implementation.inc(233,12) Warning: Function result does not seem to be set
oro_implementation.inc(241,12) Warning: Function result does not seem to be set
oro_implementation.inc(249,12) Warning: Function result does not seem to be set
oro_implementation.inc(257,12) Warning: Function result does not seem to be set
oro_implementation.inc(265,12) Warning: Function result does not seem to be set
oro_implementation.inc(273,12) Warning: Function result does not seem to be set
oro_implementation.inc(281,12) Warning: Function result does not seem to be set
oro_implementation.inc(289,12) Warning: Function result does not seem to be set
oro_implementation.inc(297,12) Warning: Function result does not seem to be set
oro_implementation.inc(305,12) Warning: Function result does not seem to be set
oro_implementation.inc(313,12) Warning: Function result does not seem to be set
oro_implementation.inc(321,12) Warning: Function result does not seem to be set
oro_implementation.inc(329,12) Warning: Function result does not seem to be set
oro_implementation.inc(337,12) Warning: Function result does not seem to be set
oro_implementation.inc(345,12) Warning: Function result does not seem to be set
oro_implementation.inc(353,12) Warning: Function result does not seem to be set
oro_implementation.inc(361,12) Warning: Function result does not seem to be set
oro_implementation.inc(369,12) Warning: Function result does not seem to be set
oro_implementation.inc(377,12) Warning: Function result does not seem to be set
oro_implementation.inc(385,12) Warning: Function result does not seem to be set
oro_implementation.inc(393,12) Warning: Function result does not seem to be set
oro_implementation.inc(401,12) Warning: Function result does not seem to be set
oro_implementation.inc(409,12) Warning: Function result does not seem to be set
oro_implementation.inc(417,12) Warning: Function result does not seem to be set
oro_implementation.inc(425,12) Warning: Function result does not seem to be set
oro_implementation.inc(433,12) Warning: Function result does not seem to be set
oro_implementation.inc(441,12) Warning: Function result does not seem to be set
oro_implementation.inc(449,12) Warning: Function result does not seem to be set
oro_implementation.inc(457,12) Warning: Function result does not seem to be set
oro_implementation.inc(465,12) Warning: Function result does not seem to be set
oro_implementation.inc(473,12) Warning: Function result does not seem to be set
oro_implementation.inc(481,12) Warning: Function result does not seem to be set
oro_implementation.inc(489,12) Warning: Function result does not seem to be set
oro_implementation.inc(497,12) Warning: Function result does not seem to be set
oro_implementation.inc(505,12) Warning: Function result does not seem to be set
oro_implementation.inc(513,12) Warning: Function result does not seem to be set
oro_implementation.inc(521,12) Warning: Function result does not seem to be set
oro_implementation.inc(529,12) Warning: Function result does not seem to be set
oro_implementation.inc(537,12) Warning: Function result does not seem to be set
oro_implementation.inc(545,12) Warning: Function result does not seem to be set
oro_implementation.inc(553,12) Warning: Function result does not seem to be set
oro_implementation.inc(561,12) Warning: Function result does not seem to be set
oro_implementation.inc(569,12) Warning: Function result does not seem to be set
oro_implementation.inc(577,12) Warning: Function result does not seem to be set
oro_implementation.inc(585,12) Warning: Function result does not seem to be set
oro_implementation.inc(593,12) Warning: Function result does not seem to be set
oro_implementation.inc(601,12) Warning: Function result does not seem to be set
oro_implementation.inc(609,12) Warning: Function result does not seem to be set
oro_implementation.inc(629,30) Warning: range check error while evaluating constants (2 must be between 1 and 1)
oro_implementation.inc(635,30) Warning: range check error while evaluating constants (4 must be between 1 and 1)
oro_implementation.inc(641,32) Warning: range check error while evaluating constants (5 must be between 1 and 1)
Linking test01.exe
28055 lines compiled, 0.9 sec, 152048 bytes code, 6548 bytes data
66 warning(s) issued
1 note(s) issued

when I tried to run test01.exe, a dialog appeared and said "system error, can not find oci.dll, can not execute the program. reinstall may solve this problem."

there are files named as oci.inc, oci.pp, oci.ppu and oci.o. according to the timestamp, oci.ppu and oci.o are created while compiling. I don't know why it asked for a oci.dll.
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: TRon on June 22, 2020, 02:38:42 pm
Thank you senglit.

Unfortunately something went a bit wrong there  ;D

- copy <your FPC source location>/packages/openssl/src/*.* to <work>

i did wrote openssl ?  :D

Compiling oraclew.pp
Compiling oci.pp
Compiling oratypes.pp
oratypes.pp(300,12) Warning: Function result does not seem to be set
Those files are located in another directory named "oracle"  :)

could you try again with deleting everything from your temporary work directory <work> and copying the (correct) openssl directory and the the correct test example "test1.pas" located in the openssl examples directory ?
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: senglit on June 22, 2020, 02:58:33 pm
could you try again with deleting everything from your temporary work directory <work> and copying the (correct) openssl directory and the the correct test example "test1.pas" located in the openssl examples directory ?

Thanks for your warm hearted quick reply. this time I got this:

C:\tmp>fpc -B test1
Free Pascal Compiler version 3.2.0 [2020/06/04] for i386
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test1.pas
Compiling openssl.pas
Writing Resource String Table file: openssl.rsj
test1.pas(15,6) Warning: Symbol "InitSSLInterface" is deprecated
Linking test1.exe
5737 lines compiled, 0.8 sec, 80320 bytes code, 7764 bytes data
1 warning(s) issued

C:\tmp>test1
Load OK, missing functions:
Version :

C:\tmp>

It seems ok now. InitSSLInterface works. And there is no unavaliable functions. But it can not get the openssl version.

So, does it mean FPC3.2.0 32bit works well with openssl, And my problem may come from some other places? Do you suggest that I uninstall lazarus 64bit version and install a 32 bit version.

I guest lazarus 2.0.8 32bit + fpc3.2.0 32bit + openssl 1.0.2u 32bit should work under win10 64bit.
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: TRon on June 22, 2020, 03:29:30 pm
Thank you for testing and reporting back senglit

Finally, we are getting somewhere :-)

C:\tmp>test1
Load OK, missing functions:
Version :

C:\tmp>

It seems ok now. InitSSLInterface works. And there is no unavaliable functions.
A perfect (as in expected result). Three hurrays for yourself  :D

Quote
But it can not get the openssl version.
That is correct. It was recently removed from trunk because ssleasy libraries did not seem to comply to the (openssl) standard.

Quote
So, does it mean FPC3.2.0 32bit works well with openssl,
That is a correct assumption.

Quote
And my problem may come from some other places?
Also that is a correct assumption.


Quote
Do you suggest that I uninstall lazarus 64bit version and install a 32 bit version.
Your current issues seem to originate from having a Lazarus installed that is not equipped (by default) with Free Pascal 3.2.0

What the test you just did proofed is that the Lazarus installed on your system still uses the old openssl units. Installing an out of date lnet package from OPM just made the symptoms worse.

(i was busy setting/testing things up myself, hence the delay. sorry for that: afaict Lazarus 2.0.8 works without issues with FPC 3.2.0).

afaik you got two options:
1) compile FPC 3.2.0 from source to create your own 64 bit version (since FPC developers do not distribute the 64-bit version i can only assume this to be problematic/difficult to realise) and then build Lazarus 2.0.8. from source with that FPC 3.2.0 64-bit version.
2) install 32-bit FPC 3.2.0 (you already did that), and make your own Lazarus 2.0.8 from source with that (also 32 bit). and then create or download a FPC 3.2.0 cross-compiler that is able to compile from 32 bit to 64 bit.

Option 2 is more in line with what you were already expecting so i would say: "go for it" ?  ;)

Quote
I guest lazarus 2.0.8 32bit + fpc3.2.0 32bit + openssl 1.0.2u 32bit should work under win10 64bit.
When using 32 bit openssl libraries  yes, that you have just proofed.

Another test you could perhaps do (but might proof to difficult), is that I remember you had the 32 to 64 bit FPC 3.2.0 cross-compiler installed. You should be able to use that compiler and check if that same test1.pas file also compiles with that compiler. But then you should remove the 32-bit openssl libraries from your <work> directory first (and replace them with copies of the 64-bit versions of the openssl libraries).

If that works then you proofed yourself that it works for both 32-bit and 64-bit applications. It is not necessary though, unless you are bound to creating a 64-bit application.

Easiest solution: install 32 bit FPC and build your own Lazarus 2.0.8, then install the 32 to 64 bit cross compiler in case you do wish to target 64-bit. it is only one setting on your project options to cross compile (provided that you have setup the compiler and cross-compiler correctly)

edit: i forgot to mention that there is one more easier solution: wait for Lazarus team to release the next version of Lazarus. It will include FPC 3.2.0 by default (but i have no idea how long the wait for that will be).
Title: Re: Fail to load ssleay32.dll libssl32.dll
Post by: senglit on June 23, 2020, 01:48:02 pm
Easiest solution: install 32 bit FPC and build your own Lazarus 2.0.8, then install the 32 to 64 bit cross compiler in case you do wish to target 64-bit. it is only one setting on your project options to cross compile (provided that you have setup the compiler and cross-compiler correctly)

I did as this solution and it works. Thanks!
Title: Re: [CLOSED] Fail to load ssleay32.dll libssl32.dll
Post by: TRon on June 23, 2020, 10:27:56 pm
@senglit:

Sorry that you had to go through so much trouble in order to get things working for you.

And just as you are facing these issues a new (upcoming in a week or two) release was announced.

Don't forget that lnet in OPM, even though you upgraded your Lazarus and FreePascal, is still outdated. You would have to download the sources from github and compile/install it manually in order for it to work in production.

Thanks for the feedback.
Title: Re: [CLOSED] Fail to load ssleay32.dll libssl32.dll
Post by: senglit on July 14, 2020, 07:11:45 am
@senglit:

Sorry that you had to go through so much trouble in order to get things working for you.

And just as you are facing these issues a new (upcoming in a week or two) release was announced.

Don't forget that lnet in OPM, even though you upgraded your Lazarus and FreePascal, is still outdated. You would have to download the sources from github and compile/install it manually in order for it to work in production.

Thanks for the feedback.

After re-build with Lazarus 2.0.10 and FPC 3.2.0, everything is ok now. Thanks for your effort!
Title: Re: [CLOSED] Fail to load ssleay32.dll libssl32.dll
Post by: TRon on July 14, 2020, 07:31:51 am
After re-build with Lazarus 2.0.10 and FPC 3.2.0, everything is ok now. Thanks for your effort!
Again, thank you for the feedback.

Indeed, besides the required updated sources for ssl which are present in FreePascal 3.2.0 there seem to have been some updates with regards to other (lazarus) internet related packages as well.

Still a pity you ran into this. Imagine you had started your project a couple of weeks later after this release. That would have been much less headache  ;)
TinyPortal © 2005-2018