0
votes

I am getting when trying to access a MySql database :

[FireDac][Phys][MySQL]-314. Cannot load vendor library [libmysql.dll or libmysqlld.dll]

This did not previously happen with this (unchanged) code, however, I have upgraded to Windows 10 and had to reinstall Delphi XE8, so it is obviously a system configuration matter.

In order to try to solve the problem, I copied both of those files into c:\windows\sysytem32.

When that did not seem to work, I copied them into \win32\debug, which is where the generated .EXE resides.

I imagine that I am doing something rather stupid, but can't see what.

2
Please stop copying files to system32. And FWIW, that's the 64 bit system directory so your 32 bit process can't see it. And please also don't copy them to syswow64, the 32 bit system directory, because that's also not yours to modify.David Heffernan
@Ken, thanks, that did the trick. Could you please post it as an answer, so that I Can accept it & make things clear for anyone who reads this question in future?Mawg says reinstate Monica
Feel free to write you own answer. If that answer suggests using system directory, then I'll gladly down vote!David Heffernan
@David, you have been virulently anti-system directory throughout your post. Could you please enlighten me as to why? Copying to the app directory is burdensome, if you code a lot of apps, so it is more natural to place the DLLs in a directory on the search path. Why not a system directory, since that used to be the preferred way (AFAIK)? Thanks in advance for your helpMawg says reinstate Monica
It has never been the correct way. The system directory belongs to the system MS has always said not to modify it. Imagine if app A and app B want to use different versions of the same named DLL. Then what. Copying to the app directory is not a burden. It allows you simple installation, isolation, self-determination.David Heffernan

2 Answers

3
votes

The proper solution is to place the driver file (eg., libmysql.dll) in your application's folder, or to place the installation location in your FDDrivers.ini file:

[MySQL]
Vendor=<folder>\libmysql.dll

(Recent versions of the documentation seem to use VendorLib instead of Vendor in the INI file.)

See the RAD Studio documentation topics Configuring Drivers (FireDAC) and Connect to MySQL Server (FireDAC) for more information.

1
votes

Let me to answer in two point.

  1. Developing, live database connection! Hope you have on your data module an "TFDPhysMySQLDriverLink" component. Click this component and browse your LibMySQL.DLL into VendorLib. Should be work. But only in design time.
  2. Runtime. Hopefully your DM created firstly in your project. In the DM's OnCreate event, you have to disconnect your library (I always ran my project with no database connection) and replace your "TFDPhysMySQLDriverLink"'s Vendorlib to LibMySQL.DLL (which is copied your which is copied where the generated .EXE resided)

Have a nice day!