[fpc-devel] Problem loading 2 dlls created on Free Pascal

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Thu Jul 13 04:42:14 CEST 2006


Hello,

I am experiencing a problem with libraries on Free Pascal 2.0.2. It
seams that a software cannot load 2 dlls created with Free Pascal.
Loading the first library will be successfull, but loading the second
library will fail. All of this is on Windows XP.

I noticed this when Apache would successfully load one module created
with Free Pascal, but misteriously fail when loading a second module
created on Free Pascal. Then I noticed that loading only the second
module works.

Is this a known problem that I can do something to work around, or I
should report this as a bug?

I was able to create a very simple example to reproduce the problem.
Bellow is a empty library code:

library newlib;

{$mode objfpc}{$H+}

begin
end.

It generates newlib.dll file. Then I copy that file to create a second
one newlib2.dll. It could be another library created with Free Pascal
too.

Bellow is a program that will load both Libraries:

program loadmod;

{$mode objfpc}{$H+}

{$apptype console}

uses Classes, Windows;

var
  Lib, Lib2: HINST;
begin
  Lib := LoadLibrary('C:\Programas\Apache\pmodules\newlib.dll');
  Lib2 := LoadLibrary('C:\Programas\Apache\pmodules\newlib2.dll');
  WriteLn(Lib);
  WriteLn(Lib2);
  Sleep(5000);
  FreeLibrary(Lib);
  FreeLibrary(Lib2);
end.

The WriteLn statements show that the first library is loaded
successfully. The second will return zero.

If the second library being loaded is not created with Free Pascal (I
tested with libhttpd.dll). The load will be successfull.

thanks,
-- 
Felipe Monteiro de Carvalho



More information about the fpc-devel mailing list