【问题标题】:Unresolvable linking error E2065 with XXH32 (xxHash and lz4)无法解决的链接错误 E2065 与 XXH32(xxHash 和 lz4)
【发布时间】:2014-11-07 17:30:35
【问题描述】:

我目前正在更新/编写delphi binding for lz4 & xxHash。

编译器错误is available here的项目状态。

xxHash.pas 行不通

function XXH32 (const AInput: Pointer; ALength: Integer; ASeed: Cardinal):  Cardinal; cdecl; external name '_XXH32';

尝试从 xxHash.o 绑定函数 XXH32 时,会导致错误 E2065。

[dcc32 Fehler] xxHash.pas(122): E2065 Ungenügende Forward- oder External-Deklaration: 'XXH32'

我不明白的是,所有其他功能都已绑定并且可以正常工作。

当我通过创建转储文件分析 xxHash.o 时,该函数与 xxHash.o 中的其他函数一样存在

Objdump 命令:

objdump -D xxhash.o > xxhash.o.txt

xxH32 的转储文件部分:

xxhash.o:     file format pe-i386
Disassembly of section .text:
00000000 <_XXH32>:
   0:   55                      push   %ebp
   1:   57                      push   %edi
   2:   56                      push   %esi
   3:   53                      push   %ebx
   4:   83 ec 14                sub    $0x14,%esp
   7:   8b 44 24 28             mov    0x28(%esp),%eax
   b:   8b 4c 24 2c             mov    0x2c(%esp),%ecx
...

有什么建议吗?

最小实现:

program lz4_minimal;

{$APPTYPE CONSOLE}

{$L xxhash.o}

function XXH32 (const AInput: Pointer; ALength: Integer; ASeed: Cardinal):  Cardinal; cdecl; external name '_XXH32';
function XXH64 (const AInput: Pointer; ALength: Integer; ASeed: UInt64):    UInt64;   cdecl; external name '_XXH64';

//necessary dependencies
function  _malloc(size: cardinal): Pointer; cdecl;
begin
  GetMem(Result, size);
end;

procedure _memcpy(dest, source: Pointer;  count: Integer); cdecl;
begin
  Move(source^, dest^, count);
end;

procedure _free(P: Pointer); cdecl;
begin
 FreeMem(P);
end;

begin
end.

xxHash.o 是 Windows 的 32 位,使用 MinGW 4.8.1 构建。以及 Yann Collet 在修订版 r36 中的原始源代码,包含在 lz4 中。包含生成文件。

objectfile可以在github上找到here

【问题讨论】:

  • 重命名函数没有帮助
  • 那是E2065 Unsatisfied forward or external declaration。至于为什么会遇到它,很难说。如果我们可以尝试在一个可能有用的简单缩减项目中重现。
  • 如何在此处附加目标文件?
  • 你是如何制作这个对象的?哪个编译器?哪个目标?您不能在此处附加对象。它必须在场外。
  • 我添加了必要的信息。 MinGW 带有交付的 lz4 生成文件,windows 平台,x86。尝试链接 .o 文件时,RadStudio XE3 是否存在任何已知错误?

标签: delphi gcc mingw static-linking delphi-xe3


【解决方案1】:

David Heffernan 也提出了一种解决方法,即在 xxHash.c 中添加一个虚拟函数作为第一个函数。

新的转储文件如下所示:

xxhash.o:     file format pe-i386
Disassembly of section .text:
00000000 <_XXDUMMY>:
   0:   b8 2a 00 00 00          mov    $0x2a,%eax
   5:   c3                      ret    
   6:   8d 76 00                lea    0x0(%esi),%esi
   9:   8d bc 27 00 00 00 00    lea    0x0(%edi,%eiz,1),%edi

00000010 <_XXH32>:
  10:   55                      push   %ebp
  11:   57                      push   %edi
  12:   56                      push   %esi
....

使用这个 hack 编译项目,错误消失了。

分析其他目标文件并尝试绑定第一个引用的函数总是会导致错误 E2065。

在 Delphi 中使用 MinGW 和 gcc 编译的 .o 文件似乎存在一个普遍问题。

【讨论】:

  • 您要提交错误报告吗?
  • 是的,周一我回来工作。在此之前我会用 xe7 试试这个。我昨天才准备好 xe3。
  • qc.embarcadero.com/wc/qcmain.aspx?d=128802 Bugreport 已关闭,没有真正的反馈。似乎不是有效或允许的目标文件格式。我对 ebc 给出的反馈感到失望。
  • 是的,确实很差。我猜他们不在乎。
猜你喜欢
  • 2016-12-12
  • 1970-01-01
  • 2010-11-01
  • 2018-09-23
  • 2019-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-25
相关资源
最近更新 更多