Recent

Author Topic: Application doesn't start after including DLL  (Read 1474 times)

Weitentaaal

  • Hero Member
  • *****
  • Posts: 503
  • Weitental is a very beautiful garbage depot.
Application doesn't start after including DLL
« on: February 25, 2021, 04:56:40 pm »
Hello Guys :)

So Today i tried to include a Dll like that :

Code: Pascal  [Select][+][-]
  1.    { ----- dll-files ----- }
  2.    libCAL_CC = 'CoilCalc.dll';
  3.    LIbCAL_CD = 'C:\WGKBlck\DBM\calcdll.dll';
  4.  
  5.    //CoilCalc
  6.    Function CoilCalc (Inpt : PChar;var Buffer : PChar) : LongInt; stdcall; external libCAL_CC;
  7.    //StartJob
  8.    Function StartJob (p1 : Single; p2, p3 : Variant) : Boolean; stdcall; external LIbCAL_CD;
  9.  

The "CoilCalc.dll" did work (used it many times before)
But When i included the Second 1 the Application didn't Start (No Messages) just noticed it was Debugging and after that (Finished or not) it Stoped.

Can Some1 Help me Please ?
Lazarus: 2.0.12 x86_64-win64-win32/win64
Compiler Version: 3.2.2

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: Application doesn't start after including DLL
« Reply #1 on: February 25, 2021, 05:53:48 pm »
But When i included the Second 1 the Application didn't Start (No Messages) just noticed it was Debugging and after that (Finished or not) it Stoped.
The fact that you didn't get any message means the problem is most likely in the initialization of the LibCAL_CD dll or in one of its functions the program calls early during its initialization.

Posting more code from the DLL and the program that uses it would likely be useful to give you additional help.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Application doesn't start after including DLL
« Reply #2 on: February 25, 2021, 06:45:55 pm »
Hello Guys :)

So Today i tried to include a Dll like that :

Code: Pascal  [Select][+][-]
  1.    { ----- dll-files ----- }
  2.    libCAL_CC = 'CoilCalc.dll';
  3.    LIbCAL_CD = 'C:\WGKBlck\DBM\calcdll.dll';
  4.  
  5.    //CoilCalc
  6.    Function CoilCalc (Inpt : PChar;var Buffer : PChar) : LongInt; stdcall; external libCAL_CC;
  7.    //StartJob
  8.    Function StartJob (p1 : Single; p2, p3 : Variant) : Boolean; stdcall; external LIbCAL_CD;
  9.  

The "CoilCalc.dll" did work (used it many times before)
But When i included the Second 1 the Application didn't Start (No Messages) just noticed it was Debugging and after that (Finished or not) it Stoped.

Can Some1 Help me Please ?

With external and fpc you may not define the complete path of the library.

Code: Pascal  [Select][+][-]
  1. LIbCAL_CD = 'C:\WGKBlck\DBM\calcdll.dll';

Before linking, fpc will strip C:\WGKBlck\DBM and keep-look for calcdll.dll defined in your library-search-path.

In Windows it may be in the \system\ directory for example.
So just copy your library there or update the search-directory path.

But if you want to assign a custom path, then you should use dynamic loading of libraries and LoadLibrary().
« Last Edit: February 25, 2021, 07:02:38 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Application doesn't start after including DLL
« Reply #3 on: February 25, 2021, 07:27:15 pm »
Hi!

Toto, we're not in Win95 anymore!

Read this carefully where to put (or hide) your DLL:

https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order


As always with M$: 50 ways to leave your lover ....

Winni

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: Application doesn't start after including DLL
« Reply #4 on: February 25, 2021, 10:13:24 pm »
Possibilities:
- 32-bit vs 64-bit problem? Main program one, dll the other?
- dependencies of the DLL
- multiple versions of the dll and/or its dependencies.

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Application doesn't start after including DLL
« Reply #5 on: February 26, 2021, 12:29:14 am »
I guess the question would be now is, what version of Lazarus and are you doing GUI objects in the DLLs?
The only true wisdom is knowing you know nothing

Weitentaaal

  • Hero Member
  • *****
  • Posts: 503
  • Weitental is a very beautiful garbage depot.
Re: Application doesn't start after including DLL
« Reply #6 on: February 26, 2021, 08:24:16 am »
I guess the question would be now is, what version of Lazarus and are you doing GUI objects in the DLLs?

The DLL is not Doing anything with my GUI, Thanks

Possibilities:
- 32-bit vs 64-bit problem? Main program one, dll the other?
- dependencies of the DLL
- multiple versions of the dll and/or its dependencies.

Main Programm is executed as 32 Bit. I will check the DLL, Thanks.

Hi!

Toto, we're not in Win95 anymore!

Read this carefully where to put (or hide) your DLL:

https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order


As always with M$: 50 ways to leave your lover ....

Winni

Thats a Lot of confusing Stuff right there but im Sure i put it right with an ok Name, Thanks.

Hello Guys :)

So Today i tried to include a Dll like that :

Code: Pascal  [Select][+][-]
  1.    { ----- dll-files ----- }
  2.    libCAL_CC = 'CoilCalc.dll';
  3.    LIbCAL_CD = 'C:\WGKBlck\DBM\calcdll.dll';
  4.  
  5.    //CoilCalc
  6.    Function CoilCalc (Inpt : PChar;var Buffer : PChar) : LongInt; stdcall; external libCAL_CC;
  7.    //StartJob
  8.    Function StartJob (p1 : Single; p2, p3 : Variant) : Boolean; stdcall; external LIbCAL_CD;
  9.  

The "CoilCalc.dll" did work (used it many times before)
But When i included the Second 1 the Application didn't Start (No Messages) just noticed it was Debugging and after that (Finished or not) it Stoped.

Can Some1 Help me Please ?

With external and fpc you may not define the complete path of the library.

Code: Pascal  [Select][+][-]
  1. LIbCAL_CD = 'C:\WGKBlck\DBM\calcdll.dll';

Before linking, fpc will strip C:\WGKBlck\DBM and keep-look for calcdll.dll defined in your library-search-path.

In Windows it may be in the \system\ directory for example.
So just copy your library there or update the search-directory path.

But if you want to assign a custom path, then you should use dynamic loading of libraries and LoadLibrary().


I Will Try this as next ... If this Reply gets edited ..then u will know if it worked


But When i included the Second 1 the Application didn't Start (No Messages) just noticed it was Debugging and after that (Finished or not) it Stoped.
The fact that you didn't get any message means the problem is most likely in the initialization of the LibCAL_CD dll or in one of its functions the program calls early during its initialization.

Posting more code from the DLL and the program that uses it would likely be useful to give you additional help.


DLL Did Work exactly as it Should in my VB6 Code. just a different call from a different IDE, i guess..

Edit: it was a Problem with The Path, i guess. i put all my dll's in my Project order and it worked, still got Access violation, but i got the dll running !

Thank u Guys for ur Help. :)
« Last Edit: February 26, 2021, 08:32:13 am by Weitentaaal »
Lazarus: 2.0.12 x86_64-win64-win32/win64
Compiler Version: 3.2.2

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Application doesn't start after including DLL
« Reply #7 on: February 26, 2021, 11:27:56 pm »
I assume the "StartJob" is coming from the second DLL ?

If so it most likely has something to do with the Variant type you are using....

I really don't think Delphi and VB used the same internal structure...

Also, you should be passing the variants via reference, you are doing it by value currently which just puts it all on the stack.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018