0

{$mode objfpc}{$H+}

uses
  Classes
  { you can add units after this };

function ret_num():integer; cdecl;
begin
  Result := 2;
end;

exports ret_num;

begin
end.

как сделать что б я мог вызвать функцию ret_num в другой прогремме. Вот так выдает ошибку.


{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;


implementation


{$R *.lfm}

{ TForm1 }
function ret1 () :integer; cdecl; external 'libGUMod.so';

procedure TForm1.Button1Click(Sender: TObject);
begin
    ShowMessage(IntToStr(ret1()));
end;

end.``` 

1 ответ 1

0

Имя функции в модуле (ret1) должно совпадать с именем вызываемой функции из библиотеки (ret_num): function ret_num () :integer; cdecl; external 'libGUMod.so';

Либо в библиотеке указать псевдоним функции: exports ret_num name 'ret1';

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.