Lazarus

Installation => Windows (32/64) => Topic started by: stephb on May 16, 2021, 07:06:23 pm

Title: IMPORTING A DLL
Post by: stephb on May 16, 2021, 07:06:23 pm
My system is Win10 and Lazarus 2.0.10 with freepascal 3.2.0.

I have successfuly converted a Delphi 7 project. This project makes use of two Windows dll's. The following code worked successfully when compiled with Delphi, but not with Lazarus. Lazarus build is successful so syntax seems OK, it is execution that is problematic.

the variable Wes5Handle is returned as a zero so the message 'Unable to load Wes5ENG.dll' is displayed.

Code is below, any input would be appreciated.

  Wes5Handle := LoadLibrary('Wes5ENG.dll');
  if Wes5Handle <> 0 then
    @ftn_Wes5ENG := GetProcAddress(Wes5Handle,'_ftn_wes5eng@116')
  else
    MessageDlg('Unable to load Wes5ENG.dll',mtError,[mbAbort],0);
  if (@ftn_Wes5ENG = nil) then
    MessageDlg('Could not import function from Wes5ENG.dll',mtError,[mbAbort],0);

 
Title: Re: IMPORTING A DLL
Post by: MarkMLl on May 16, 2021, 07:12:20 pm
https://www.freepascal.org/docs-html/current/rtl/system/getloaderrorstr.html

MarkMLl
Title: Re: IMPORTING A DLL
Post by: engkin on May 16, 2021, 07:26:57 pm
You did not mention if the DLL is 32-bit or 64-bit, nor did you say if your application matches it. I guess they do not match.
Title: Re: IMPORTING A DLL
Post by: stephb on May 16, 2021, 08:31:14 pm
My apologies for not giving all that detail. The dll was developed pre-2008 in FORTRAN, most probably 32-bit. I used stdcall, had to convert all arrays to C.

Lazarus now (I assume) is 64 bit, I haven't checked, just installed.

Problem is I only have Intel 32-bit compiler, will now try and see if I can compile with gfortran, I have no experience with grfortran.

Thanks again



Title: Re: IMPORTING A DLL
Post by: marcov on May 16, 2021, 08:56:04 pm
Both sides (application and dll must be the same, either 32-bit or 64-bit).

So upgrade DLL or change lazarus edition
TinyPortal © 2005-2018