Delphi and dll versions

First, forgive me if this is a student's question :)

We have several applications that Delphi user dbxpress to access MySQL 5 server. These applications were written in Delphi 2007 against libmysql.dll version 5.0.xx (actual version forgotten)

This DLL has been distributed to all users and works fine.

I just upgraded to Delphi 2010 and found that libmysql 5.1.xx user is required to access MySQL servers.

The problem is that if I replace the 5.0.xx libmysql with a newer one, existing applications won't start. On the other hand, Delphi 2010 won't work with old dlls.

While I can get both versions of the IDE (2007 and 2010) to work with the database by placing the respective dll versions in the application \ bin folder, this does not solve the problem for users.

Any suggestions on how I can get the applications to look for the corresponding dll version.

We hoped that we didn't have to immediately move all our applications to Delphi 2010 ...

+2


source to share


4 answers


There are several ways: check search order Dynamic-Link Library and redirect the dynamic link library . The safest is to place the DLLs in the application executable folder because it was checked first. Given today's disk size, this may not be a disk space issue. DLL may also not participate in processes, but this is also not a problem.



+4


source


Welcome to DLL Hell!

To fix this, you need to install version 5.1 to a different folder from version 5.0 and make sure each application looks at the correct version. Thus, you cannot simply replace the old version with the new one.

However, check if the old apps will work with the new 5.1 version. Sometimes this will work as the size of the DLL has not changed, just the code inside. If they fail, you need to support two different versions.



In the past, I just solved this by copying the MySQL libraries into the application binary folder. This way I could support multiple MySQL versions. It's not practical, but it can work if you're careful enough.

I am currently using SQL Server, so this is a problem from the past for me.

+4


source


Just about the problem with libmysql library

Here is an excerpt from a blog post

Well, every MySQL sub-version release creates a new API version and changes, so for 5 and 5.1 you will need two API Bindings. This is not all. In 5.1, each minor version also creates a new API changes, so each version (no matter how small) MySQL has a different API. It is a nightmare to keep in touch with the database.

Full blog post here

You are not alone...

Perhaps the solution might be to use the MySQL devart direct mode driver which doesn't need the DLL

+1


source


What should I do, rename the file to libmysql5.1.51.dll and place it in the application launch folder. My SqlLibraryInit () code includes:

const  lib = 'libmysql5.1.51.dll';
...
libmysql_fast_load(lib);

      

This way, by changing the constant, I can load the one I want to use.

0


source







All Articles