[fpc-pascal] dll with windows impossible???

Michel Meunier michel.meunier100 at wanadoo.Fr
Thu Jan 25 05:23:00 CET 2007


Michael Van Canneyt a écrit :
> On Wed, 24 Jan 2007, Michel Meunier wrote:
>
>   
>> Michael Van Canneyt a écrit :
>>     
>>> On Wed, 24 Jan 2007, Michel Meunier wrote:
>>>
>>> [cut code]
>>>   
>>>       
>>>> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>>> and IT DOESN'T WORK, why? It is exactly the same code!
>>>> More and more I think I am going to translate my code in C, because FPC
>>>> seems
>>>> unable to manage properly dll library.
>>>>     
>>>>         
>>> It has nothing to do with FPC. 
>>>
>>> 1. Compile the DLL without debug info. 
>>>    (lazarus compiles it by default with debug info included. Disable that)
>>>   
>>>       
>> it's the case
>>     
>>> 2. ALWAYS specify the complete path to the DLL. Do NOT assume that
>>>    the program is started with as the current directory the program
>>>    directory.  This is a common mistake.
>>>
>>>   
>>>       
>> Ok, I have tried, and the problem is the same :-(
>>     
>
> 1. What is the return value of LoadLibrary ? Have you checked it ?
>   
the return value is 0
> 2. If it is <>0 immediatly get the last error: raiselastoserror.
>    This should give you at least a hint why windows thinks it can't load your library.
>   
when I make a test with Lazarus, I get this message:
project raises exception class 'External: SIGSEGV'
and next, in another window:

execution stopped
Adress: $7C92E183
procedure: ntdll!LdrFindRessource_U
File:

And I have also replaced my 'testdll.dll' by a dll compiled with Delphi 
and next renamed 'testdll.dll', and it's ok, so the problem is with
the library compile with FPC.
> 3. Did you specify $APPTYPE GUI in the library as well ?
>    If not, do so. Otherwise the library will try to initialize the terminal, 
>    when it cannot: there is none, since the loading program does not have one!
>   
I have added:
{$APPTYPE GUI}
just after 'library dlltest;' in the code and no change.
> 4. You can also try vice versa: specify apptype console in your GUI program.
>    The GUI will still run, but in addition a terminal will be opened, allowing
>    the library to initialize it.
>   
I have added: {$APPTYPE CONSOLE} in the GUI program to test the dll, and 
no change.
> Can you test all this, please ?
>
> Michael.
OUPS, i have found the solution, in the linking part, the option -gl was 
set, it's difficult to translate in english, but it's to insert the 
number of lines in case of debug. And now it's working!! Whaou, thanks a 
lot for your help.



-- 
Michel Meunier

Web: www.etoiles-a-bleau.fr





More information about the fpc-pascal mailing list