tags:

views:

580

answers:

4

First off, forgive me if this is a schoolboy question :)

We have a number of applications that user Delphi dbxpress to access a MySQL 5 server. These applications were all written on Delphi 2007 against a libmysql.dll version 5.0.xx (actual version forgotten)

This dll has been distributed to all users and is working fine.

I have just upgraded to Delphi 2010 and discovered that that needs to user libmysql 5.1.xx to see MySQL servers.

Trouble is, if I replace the 5.0.xx libmysql with the newer one, existing applications will not startup. On the flip side Delphi 2010 will not work with the older dll.

Whilst I can get both versions of the IDE (2007 and 2010) to work with the database by placing the appropriate dll versions in the \bin folder of the application, this doesn't solve the problem for the users.

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

We were hoping to not have to move all our applications to Delphi 2010 immediately...

+4  A: 

Welcome to the DLL Hell!

To fix this, you need to install the 5.1 version in a different folder from the 5.0 version and make sure every application will look at the right version to use. Thus you cannot just replace the old version with the new one.

However, do check if the old applications will run with the new 5.1 version. Sometimes, this will just work since the footprint of the DLL hasn't changed, just the code inside. If they do crash, you'll need to maintain two different versions.

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

Nowadays, I use SQL Server so this is a problem from the past for me.

Workshop Alex
ThanksI suppose the core question is *how* do I get the new applications to look for a dll somewhere other than System32(for example it will be easier for us to tell the new Delphi 2010 apps to use a local bin folder)
Dan Kelly
Yep. Unfortunately, while I still use Delphi 2007, I never installed the DBExpress components nor am I using MySQL these days. But basically, you need to maintain both versions on your system, in different folders.
Workshop Alex
+4  A: 

There are several methods: check Dynamic-Link Library Search Order and Dynamic-Link Library Redirection. The safest one is to put the DLLs you need in the application executable folder, because it's the first one checked. Given today's disk size, it may not be a disk space problem. The DLL may also be not share among processes, but that could not be an issue too.

ldsandon
That's what I was looking for!At the very least we can stick the dlls for the new applications local to them until we formally migrate the older stuff :)
Dan Kelly
Good call! I've forgotten about that load order. :-)
Workshop Alex
+1  A: 

Just about your libmysql dll problem

Here is an extract from blog post

Well, every release of MySQL sub-version create new API version and changes, so for 5 and 5.1 you need two API binding. That’s not all. On 5.1, each sub version also creates new API changes, so every version (regardless of how small it is) of MySQL has a different API. That’s a nightmare for maintaining communication with the database.

Full blog post here

You are not alone...

Perhaps, a solution can to be to use MySQL devart driver with direct mode who don't need dll

Hugues Van Landeghem
A: 

What I do is rename the file to libmysql5.1.51.dll, and put 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 whichever build I want to use.

Guy Gordon