Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

Lazarus IDE and 组件 下载地址版权申明
查看: 3588|回复: 3

谁来帮帮我,已经查了无数资料,仍然无法解决

[复制链接]

该用户从未签到

发表于 2011-8-4 23:57:00 | 显示全部楼层 |阅读模式
在CentOS6下,编写来一个调用自己的so文件的例子,没想到这么简单的一件事情,编译的时候总是报错:/usr/bin/ld: cannot find -lSOTest
研究了好多天,网山查了个遍,还是没有办法解决。下载了猫工的例子来编译,也是一样的错误。
有没有人帮我。

SOTest.so 所我自己写的动态库:
library SOTest;

{$mode objfpc}{$H+}

uses
  Classes,
  SysUtils { you can add units after this };

{$R *.res}

  function GetCurrentDate: TDateTime; cdecl; export;
  begin
    Result := Now;
  end;

exports
  GetCurrentDate;

begin
end.     


主程序如下:
unit MainFormUnit;

{$mode objfpc}{$H+}

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

function GetCurrentDate: TDateTime; cdecl; external 'SOTest.so';

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text:=DateTimeToStr(GetCurrentDate);
end;

end.
回复

使用道具 举报

该用户从未签到

 楼主| 发表于 2011-8-5 10:48:10 | 显示全部楼层
自己顶下!
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2011-8-5 11:38:35 | 显示全部楼层
不会吧,我在centos下可以调用mysql的so文件的啊
回复 支持 反对

使用道具 举报

该用户从未签到

 楼主| 发表于 2011-8-8 16:13:23 | 显示全部楼层
唉!通过不懈的努力,问题终于找到了。
在工程选项里面的路径选项当中有个 Apply conventions 的勾选项。把这个够选上就OK了。
我原来看他自己生成的文件名我不喜欢,Lazarus 会在生成的so文件前面加上lib,并且文件名都被改成了小写。我把这个勾选去掉了,自己手动修改了 Target file name(-o): 里的生成的文件名,导致连接始终不通过。
这个问题是不是Lazarus 的Bug,我不清楚。更深层的原因我就无法知晓了,希望高人能够指导下。
回复 支持 反对

使用道具 举报

*滑块验证:

本版积分规则

QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

GMT+8, 2025-5-2 05:29 , Processed in 0.060683 second(s), 9 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表