* * *

Author Topic: No warnings given for 32-bit dll's  (Read 483 times)

User137

  • Hero Member
  • *****
  • Posts: 1688
    • Nxpascal home
No warnings given for 32-bit dll's
« on: January 09, 2017, 11:17:59 am »
I've recently switched to 64-bit compiler on Windows 10, but there are apps that still refuse to start. No error messages are given when it tries to load 32-bit dll for example. At least when dll is completely missing, it seems that when try to start the app i get error message stating which dll file is missing. But problem is when there is a dll that is same name when it's 32 or 64-bit.

The problem came with BASS audio library, but i did own modifications to its header and renamed bass.dll to bass64.dll from x64 folder.
Code: Pascal  [Select]
  1. {$IFDEF MSWINDOWS}
  2.   {$IFDEF CPU64}
  3.     bassdll = 'bass64.dll';
  4.   {$ELSE}
  5.     bassdll = 'bass.dll';
  6.   {$ENDIF}
  7. {$ENDIF}
http://www.freepascal.org/docs-html/3.0.0/prog/progap7.html <- was useful doc for finding that.

With small projects like mine, knowing i was changing from 32 to 64 it was obvious i should look into dll versions, but what if it was a bigger project and 10 dll files? Having as much as
Code: Pascal  [Select]
  1. function BASS_SetConfig(option, value: DWORD): BOOL; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external bassdll;
Declared somewhere is enough to make whole executable not start at all, no errors, no warnings.

I'm using the latest Lazarus+fpc package 1.6.2 that's with fpc 3.0.0.
« Last Edit: January 09, 2017, 11:19:36 am by User137 »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5339
Re: No warnings given for 32-bit dll's
« Reply #1 on: January 09, 2017, 11:35:03 am »
Then you must not declare your functions that way, but do it entirely under program control with loadlibrary and getproc* (unit dynlibs) and fill a procedure variable for each function you use explictely.

The dll check on startup in the way as you declare them is done by windows based on the DLL names registered in the program header, and lazarus/fpc and the started program have no control over it, and can't issue custom messages.


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus