Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-11

Inconsistency detected in dynamic library

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Hans-Peter Suter

When I execute a small program which links to a dynamic library, ld complains:

./TestExe
hello 42
Inconsistency detected by ld.so: dl-fini.c: 195: _dl_fini: Assertion `ns != 0 || i == nloaded' failed!

This is on Debian Lenny (Free Pascal Compiler version 2.2.2 [2008/07/30] for i386
, GNU ld (GNU Binutils for Debian) 2.18.0.20080103). On my Mac the code works.

I do not have much experience with fpc (on linux) and dynamic libraries and wanted to ask if there is something obvious which I do wrong. And/or what next steps I should/could do?

(in google I found a similar problem
()
but it doesn't help me).

The code is below. Thanks for tips and having a look!

Hans-Peter

--------- TestShlib.pas --
library TestShlib;
{$mode objfpc}{$H+}
uses
  SysUtils;
function hello: integer; cdecl;
  begin
    result:= 42;
  end;
exports hello;
begin
end.
--------- TestExe.pas --
program TestExe;
{$mode objfpc}{$H+}
uses
  SysUtils;
function hello: integer; cdecl; external 'TestShlib';
begin
  WriteLn( Format( 'hello %d', [hello()] ) );
end.

--------- compile/link --
fpc -CD TestShlib.pas -o./TestShlib.so
fpc -k"-R ." -k-lTestShlib TestExe.pas

Reply by email

Jonas Maebe
to Hans-Peter Suter
Hans-Peter Suter wrote
This is on Debian Lenny (Free Pascal Compiler version 2.2.2 [2008/07/30] for i386 , GNU ld (GNU Binutils for Debian) 2.18.0.20080103). On my Mac the code works.

You may want to use at least FPC 2.2.4, several bugs related to dynamic libraries on *nix platforms were fixed there.

Jonas

Reply by email

Hans-Peter Suter
to Jonas Maebe

2009/11/16 Jonas Maebe :

You may want to use at least FPC 2.2.4, several bugs related to dynamic libraries on *nix platforms were fixed there.

Thanks for your answer! - I updated to FPC 2.2.4 (*) but the inconsistency message is still there. The same happened when I tested on another (VM) machine.

<pre>
fpc -CD TestShlib.pas
Free Pascal Compiler version 2.2.4-3 [2009/06/03] for i386 Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for i386
Compiling TestShlib.pas
Linking libTestShlib.so
11 lines compiled, 0.1 sec

fpc -k"-R ." -k"-lTestShlib" TestExe.pas
Free Pascal Compiler version 2.2.4-3 [2009/06/03] for i386 Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for i386
Compiling TestExe.pas
Linking TestExe
8 lines compiled, 0.0 sec

./TestExe
hello 42
Inconsistency detected by ld.so: dl-fini.c: 195: _dl_fini: Assertion `ns != 0 || i == nloaded' failed!
</pre>

Hans-Peter

(*) wget http://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20i386%20DEB/Lazarus%200.9.28.2/fpc-2.2.4-3.i386.deb.tar/download

Reply by email