Author Topic: MYSQL8.0 LOADLIbrary Error  (Read 529 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 617
MYSQL8.0 LOADLIbrary Error
« on: August 01, 2026, 06:59:09 pm »
Hi i installed mysql 8.4 and copy dll from C:\Program Files\MySQL\MySQL Server 8.4\lib to foler where is runing my app but when load library send me error installation incorrect....

how i can solve this problem

  'MySQL 8.0': begin FormMain.MySQL80C.HostName:= EHost.Text ;
                     FormMain.MySQL80C.Port:= StrToINt(Eport.Text);
                     FormMain.MySQL80C.UserName:= EUser.Text;
                     FormMain.MySQL80C.Password:=EPswd.Text;
                     FormMain.SQLDBL.ConnectionType:= CbProtocol.Text;
                     FormMain.SQLDBL.LibraryName:=FNELib.FileName ;
                     if( FileExists(FNELib.FileName)) then begin
                        ShowMessage(FormMain.SQLDBL.LibraryName);
                     end;
                     FormMain.SQLDBL.LoadLibrary;  //here produce error
                     FormMain.MySQL80C.Connected:=true;
               end;


Thanks
Fernando

jamie

  • Hero Member
  • *****
  • Posts: 8029
Re: MYSQL8.0 LOADLIbrary Error
« Reply #1 on: August 01, 2026, 09:08:13 pm »
You may have incorrect bit-ness DLL file.

you need to ensure that you have the 32-bit version of the libs for a 32-bit app and 64 bit one for that too.

Also, you may need to install those files within the same folder as your application.

Jamie
The only true wisdom is knowing you know nothing

eldonfsr

  • Hero Member
  • *****
  • Posts: 617
Re: MYSQL8.0 LOADLIbrary Error
« Reply #2 on: August 01, 2026, 11:54:57 pm »
You think lazarus and my App is runing 32 bits and dll is 64 bits

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1329
Re: MYSQL8.0 LOADLIbrary Error
« Reply #3 on: August 02, 2026, 01:00:42 am »
I have things set up so I never have to worry about this.  Let the compiler work it out for me.  Can't give you specific code, it's spread across application and libraries.   Here's the general idea though:

I store all my drivers in the following folder structure. Means there was a little extra effort getting the 32bit and 64bit drivers for all of DBs I use...

  • "<exepath>\Drivers\sqlite\i386\sqlite3.dll"
  • "<exepath>\Drivers\sqlite\x86_64\sqlite3.dll"
  • "<exepath>\Drivers\mariadb\i386\libmariadb.dll"
  • "<exepath>\Drivers\mariadb\x86_64\libmariadb.dll"
  • "<exepath>\Drivers\mysql\i386\libmysql.dll"
  • "<exepath>\Drivers\mysql\x86_64\libmysql.dll"
(you get the idea - and I use the same code for video playback drivers)

I have a routine that I pass the name of the driver I want ('sqlite', 'mariadb' etc), and I have a VERSION.txt in each of the base folders that covers where & when I got the drivers so I can update if needed.

Code: Pascal  [Select][+][-]
  1. Function GetCPU: String;
  2. Begin
  3.   Result := {$I %FPCTARGETCPU%};
  4. End;

This returns the correct i386 or x86_64 part of the path.

So my code always loading the correct DLL, regardless of which compiler/IDE I used.

Hope this makes sense.  If I need to I can draw all the bits together into a single routine, it's not much though...
Lazarus Trunk/FPC latest fixes on Windows 11
  How to use the forum:  https://wiki.lazarus.freepascal.org/Forum

eldonfsr

  • Hero Member
  • *****
  • Posts: 617
Re: MYSQL8.0 LOADLIbrary Error
« Reply #4 on: August 02, 2026, 03:21:46 am »
Here my code

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1329
Re: MYSQL8.0 LOADLIbrary Error
« Reply #5 on: August 02, 2026, 07:22:29 am »
Before we look at code, let's resolve bitness.

What build of MySQL did you install? 32bit or 64bit?
What version of Lazarus/fpc are you running? 32bit or 64bit?
Lazarus Trunk/FPC latest fixes on Windows 11
  How to use the forum:  https://wiki.lazarus.freepascal.org/Forum

eldonfsr

  • Hero Member
  • *****
  • Posts: 617
Re: MYSQL8.0 LOADLIbrary Error
« Reply #6 on: August 02, 2026, 05:02:53 pm »
Here what version u using and the las changes..

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1329
Re: MYSQL8.0 LOADLIbrary Error
« Reply #7 on: August 03, 2026, 02:17:23 am »
OK, that's 1/2 of my questions answered :-)

What build of MySQL did you install?  32bit or 64bit.

99% of the time people report errors with database connections, they're using 32bit DLL drivers against 64 bit lazarus.   Before we look at code, I really want to rule this out.

Update: In your first question you specified MySQL 8.4, and that's in Program Files, not in Program Files (x86).  Not conclusive, but I'm willing to suspect 64bit MySQL.  So we can rule bitness out, at least for now.

OK, next question.  As you said you copied the DLL across, did you copy across all dependencies, or just the one DLL?   When i built my MySQL library, I needed to copy the following files as Libmysql.dll requires them:
"libmysql.dll"
"libprotobuf-lite.dll"
"libssl-3-x64.dll"
"libcrypto-3-x64.dll"

I suspect different installations will have different dependencies.  In doubt, copy ALL Dlls.  if that works, delete on by one :-)

However, I used Dependency Walker to work out which DLLs I needed.




« Last Edit: August 03, 2026, 02:35:31 am by Mike.Cornflake »
Lazarus Trunk/FPC latest fixes on Windows 11
  How to use the forum:  https://wiki.lazarus.freepascal.org/Forum

eldonfsr

  • Hero Member
  • *****
  • Posts: 617
Re: MYSQL8.0 LOADLIbrary Error
« Reply #8 on: August 03, 2026, 03:58:54 am »
Thanks i copy rest of dlls and working,,,, thanks so much

 

TinyPortal © 2005-2018