Dear All,
I used to use Turbo Pascal. I am a new user of Lazarus 4.0. I can not resolve to add the Intel MKL library to Lazarus. On the windows 10, I have defined PATH "C:\Program Files (x86)\Intel\oneAPI\mkl\latest\bin". This folder contains mkl_rt.2.dll and mkl_rt.dll. my code is like that: ********************************************
program MKLEigenSolver;
{$mode objfpc}{$H+}
{$APPTYPE CONSOLE}
uses
Windows, SysUtils;
type
TLAPACKE_dsyev = function(layout: Integer; jobz, uplo: Char;
n: Integer; a: PDouble; lda: Integer;
w: PDouble): Integer; cdecl;
const
MKL_PATH = 'C:\Program Files (x86)\Intel\oneAPI\mkl\latest\bin\';
LAPACK_ROW_MAJOR = 101;
var
hMKL: HMODULE;
dsyevFunc: TLAPACKE_dsyev;
A: array[0..8] of Double = (
4.0, 1.0, 0.5,
1.0, 3.0, 1.0,
0.5, 1.0, 2.0
);
W: array[0..2] of Double;
i: Integer;
begin
try
// Load only the main MKL DLL
WriteLn('Loading MKL runtime...');
// Try loading in preferred order
hMKL := LoadLibrary(PChar(MKL_PATH + 'mkl_rt.2.dll'));
if hMKL = 0 then
hMKL := LoadLibrary(PChar(MKL_PATH + 'mkl_rt.dll'));
if hMKL = 0 then
begin
WriteLn('ERROR: Failed to load MKL runtime library');
WriteLn('Please ensure either mkl_rt.2.dll or mkl_rt.dll exists in:');
WriteLn(MKL_PATH);
ReadLn;
Exit;
end;
// Get function pointer
WriteLn('Locating dsyev function...');
dsyevFunc := TLAPACKE_dsyev(GetProcAddress(hMKL, 'LAPACKE_dsyev'));
if not Assigned(dsyevFunc) then
begin
WriteLn('ERROR: Failed to find required function');
FreeLibrary(hMKL);
ReadLn;
Exit;
end;
// Compute eigenvalues
WriteLn('Calculating eigenvalues...');
if dsyevFunc(LAPACK_ROW_MAJOR, 'N', 'U', 3, @A[0], 3, @W[0]) = 0 then
begin
WriteLn(#13#10'RESULTS:');
for i := 0 to 2 do
WriteLn(Format('λ%d = %.6f', [i+1, W]));
end
else
WriteLn('ERROR: Eigenvalue computation failed');
except
on E: Exception do
WriteLn('FATAL ERROR: ', E.ClassName, ' -> ', E.Message);
end;
if hMKL <> 0 then
FreeLibrary(hMKL);
WriteLn(#13#10'Press Enter to exit...');
ReadLn;
end.
***************************************
the output for the error message is attached. Could you direct me to solve this matter?