Recent

Author Topic: [SOLVED] Lazarus refuses to load libmysql.dll  (Read 6505 times)

rwebb616

  • Full Member
  • ***
  • Posts: 133
[SOLVED] Lazarus refuses to load libmysql.dll
« on: February 23, 2021, 05:44:11 pm »
Hello,

I'm not sure how to fix this - I have Lazarus installed on one computer and everything with libmysql is working - I can connect/query my database and fill a dbgrid successfully.  I have the same version of lazarus and the libmysql.dll on another computer both having the same bitness on operating system (windows 10) and Lazarus keeps giving me the error "cannot load default mysql library (libmysql.dll) check your installation".

I have the DLL in the system path and just typing the name of the dll at the command line brings up an error saying it needs an application to load the dll which indicates to me that it is found in the path.  I also have the DLL in the project directory and also in the c:\lazarus directory.

What am I missing?

EDIT:  I also forgot to mention that I installed MariaDB which comes with HeidiSQL and I can use Heidi to access the database that I'm trying to access in Lazarus using the libmysql.dll (in the dropdown in heidi) and connect just fine.

Rich
« Last Edit: February 23, 2021, 09:26:09 pm by rwebb616 »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Lazarus refuses to load libmysql.dll
« Reply #1 on: February 23, 2021, 07:28:34 pm »
I don't know whether this is going to be any help. I'm not a Windows user but I've been on the periphery of some (networking) problems which turned out to be caused by Windows 10 having been installed/upgraded on different days: various system defaults in the installation download were changed a few months after it became available, and I can't remember whether there was anything useful in the OS version number that indicated its history.

So two Windows 10 systems might not be quite as identical as one assumes.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Lazarus refuses to load libmysql.dll
« Reply #2 on: February 23, 2021, 07:55:51 pm »
I'm not sure that it's really Windows related... The message comes back immediately when I change the connected property on the connection from false to true.  It doesn't even look like Lazarus is attempting to load it so I'm missing something probably really simple.  I don't remember having to add any packages to Lazarus or anything - it supposedly supports mysql 5.7 out of the box so just having the client library somewhere in the path and in the project folder seems like it would be sufficient.  I also have it in the root lazarus folder for good measure.  I've also tried downloading the mysql 5.7.32 x64 zip file and putting it's lib folder in the path - same thing.

I also tried replacing it with the dll from the mariadb lib folder that heidi SQL is using .. nothing I do seems to make any difference.  This seems very odd to me.

balazsszekely

  • Guest
Re: Lazarus refuses to load libmysql.dll
« Reply #3 on: February 23, 2021, 08:01:41 pm »
If you run the following code, what message is displayed? First make sure the exe and dll are in the same folder.
Code: Pascal  [Select][+][-]
  1. uses Windows;
  2.  
  3. procedure TForm1.Button1Click(Sender: TObject);
  4. var
  5.   LibName: WideString;
  6.   LibHandle: TLibHandle = NilHandle;
  7. begin
  8.   LibName := WideString(ExtractFilePath(ParamStr(0)) + 'libmysql.dll');
  9.   LibHandle := LoadLibraryW(PWideChar(LibName));
  10.   if LibHandle = NilHandle then
  11.     ShowMessage(SysErrorMessage(GetLastError))
  12.   else
  13.     ShowMessage('Library successfully loaded!');
  14. end;

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Lazarus refuses to load libmysql.dll
« Reply #4 on: February 23, 2021, 08:07:50 pm »
I get "The specified module could not be found" - put the libmysql.dll in the same folder as the project and the .exe.

It's also in the path.  Strange?

balazsszekely

  • Guest
Re: Lazarus refuses to load libmysql.dll
« Reply #5 on: February 23, 2021, 08:11:41 pm »
1. Make sure the bitness are the same
2. Disable AV software
3. Run the exe with elevated permissions

If still not works, please upload the dll somewhere so I can run a few tests.

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Lazarus refuses to load libmysql.dll
« Reply #6 on: February 23, 2021, 08:13:48 pm »
Just for the heck of it I put the 32 bit version in the folder and now the showmessage box comes up blank which looks like it would be nilhandle but for some reason no message.  I also tried that dll with my test app and get the same error about not being able to load. 

I've tried several different versions of the mysql dll including the one that works on my other machine.


rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Lazarus refuses to load libmysql.dll
« Reply #7 on: February 23, 2021, 08:19:51 pm »
Here is the one from my working machine:  https://files.crossfirechurch.org/index.php/s/xp4NtqL3hbF4Cec

balazsszekely

  • Guest
Re: Lazarus refuses to load libmysql.dll
« Reply #8 on: February 23, 2021, 08:29:28 pm »
Your dll is loaded without any issues at my side. Something must be wrong with your windows. A system dll can be loaded?
Code: Pascal  [Select][+][-]
  1. //...
  2. LibName := WideString('ntdll.dll');
  3. //...


rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Lazarus refuses to load libmysql.dll
« Reply #9 on: February 23, 2021, 08:37:35 pm »
Ah yes... same error "The specified module could not be found" what on earth... this is a fairly fresh install of windows too.  How is it that it works with Heidi SQL though...

Also I just went through and made sure the only copy of the dll is in the folder with the EXE .. removed all system paths with the dll in it - same issue.

Windows Version 1909

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Lazarus refuses to load libmysql.dll
« Reply #10 on: February 23, 2021, 09:03:10 pm »
Tried using regsvr32 on the dll and got this error as well.  Something is wrong somewhere!

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Lazarus refuses to load libmysql.dll
« Reply #11 on: February 23, 2021, 09:13:47 pm »
Are there any c runtime libraries or anything like that I need to install?  .net frameworks?

balazsszekely

  • Guest
Re: Lazarus refuses to load libmysql.dll
« Reply #12 on: February 23, 2021, 09:25:36 pm »
Try this:
cmd(Run as administrator)->sfc /scannow

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Lazarus refuses to load libmysql.dll
« Reply #13 on: February 23, 2021, 09:25:51 pm »
All fixed - had to install all of the VC++ redistributables and the VC Runtime libraries.  After those were installed it started working! Thanks GetMem for your help - that drove me to look for the runtimes - downloaded dependency walker and found out why they weren't loading.

Rich

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Lazarus refuses to load libmysql.dll
« Reply #14 on: February 23, 2021, 09:26:39 pm »
Is the DLL corrupt? The message could be interpreted as either "can't find it" or "it's not a DLL".

I'd not have expected any other prerequisites from the POV of the Lazarus program. From the POV of the DLL... there's always the possibility that the developers have tried to do something clever in the version you've got.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018