Recent

Author Topic: Windows 7 and MySQL Nightmare!!  (Read 13037 times)

psychojock

  • New member
  • *
  • Posts: 8
Windows 7 and MySQL Nightmare!!
« on: December 05, 2012, 12:23:26 pm »
Hi all,
I know this has been covered elsewhere(I think I've read most of the threads!),but I can't get this working.
I have a Dell N5040, Windows 7(64 Bit), Lazarus 1.04, FPC Version2.6.0.

I have numerous Applications that talk to my MySQL Databases on my server, they all run fine on my old XP(SP3) machine.  I have the libmysql.dll in the application directory,and everything is hunky-dory.

I have copied the source for these to my new machine after downloading and installing Lazarus and BOOM!!
Nothing works.  I have the 64 bit version of lazarus installed and I have tried both the 32 bit and (I think) the 64 bit version of libmysql.dll to no avail.

I am still getting the dreaded:-
 "Cannot load default MySQL Library ("libmysql.dll" or "libmysql.dll"). Check your installation.

Can anyone tell me:-

1. Where can I get a version of libmysql.dll that is guaranteed 64 Bits?
or
2. Am I better off Installing 32 Bit Lazarus, if so, what implications does that have for Windows 7 compatibilty?

Thank you.

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Windows 7 and MySQL Nightmare!!
« Reply #1 on: December 05, 2012, 12:32:44 pm »
It is also relevant to know, what version of MySQL you are using. There might be different dll-versions for each.

As for me, i just typed libmysql.dll in google and downloaded it from first result  :P  Worked fine with MySQL 5.5 with 32-bit windows 7.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Windows 7 and MySQL Nightmare!!
« Reply #2 on: December 05, 2012, 01:13:11 pm »
No idea what version are 64 bit compatible. What does the Mysql site have?
No problems with running 32 bit applications on Windows 7. In fact it may be better from a compatibilty perspective if you give it to others until everybody is using 64 bit OSes.

That said, there's nothing stopping you from building both 64 and 32 bit versions with the same code... but given your current problems, I'm sure you'd want to fix them first before even contemplating that.

There are different dll versions for the various clients. The DLL version MUST match the TMySQL* connector you use in the code. Welcome to MySQL hell... :(

Also, use 32 bit mysql client dlls for 32 bit applications, 64 bit for 64... but you probably know that by now.

Perhaps the mysql driver dll needs additional dlls as well (e.g. for compression and encryption) and will barf if they're not there.

Finally, you can try using tools like Sysinternals Process Monitor to determine what mysql dlls your application is trying to load.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

psychojock

  • New member
  • *
  • Posts: 8
Re: Windows 7 and MySQL Nightmare!!
« Reply #3 on: December 14, 2012, 11:50:07 am »
Hi Big Chimp,
Yeah I know what you mean!! MySQL is a very good database but coding Applications to talk to it can be a real pain in the butt.  I didn't even have tjis much trouble when I wrote a web/php front end to one of my databases!!! :o

I have down loaded and installed Process Monitor with shall we say, interesting results.

Initially, in the sections labelled "Create File","Query Basic Information File" and "Close File" with relation to my program and libmysql.dll, it reports SUCCESS,(with the copy in the application's working directory).

Then we get "Create File" again - SUCCESS and then "CreateFileMapping" - FILE LOCKED WITH ONLY READERS and in the details column - SyncType:   SyncTypeCreateSection PageProtection:
 :(
Any ideas?

Thanks again.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Windows 7 and MySQL Nightmare!!
« Reply #4 on: December 14, 2012, 12:25:53 pm »
Well, now you know what libmysql.dll is being accessed. No idea what the second line is doing but it's not looking for other mysql dlls so that must be ok.

Quote from: BigChimp
The DLL version MUST match the TMySQL* connector you use in the code. Welcome to MySQL hell... :(

Also, use 32 bit mysql client dlls for 32 bit applications, 64 bit for 64...
Check its properties to see if it's the right version, and check if it's 64 or 32 bit.

Then check the rest of the log to see if it's trying to load other dlls needed for mysql and failing.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

bobo

  • Full Member
  • ***
  • Posts: 171
Re: Windows 7 and MySQL Nightmare!!
« Reply #5 on: December 14, 2012, 07:29:30 pm »
I am able to create both 32bit and 64 bit Apps to use MySQL on my 64bit Windows machine (to connect to MySQL via tcp/ip locally or to remote servers). I am using the 32bit Lazarus and have cross-compiling to 64bit if I need 64bit applications.

By having 64 bit Lazarus does not guarantee that your compiled app is 64bit. In the Lazarus "Project -> Project Options -> Code Generation" use the "Target OS" and "Target CPU Family" to make sure you either have "Win64/x86_64" or "Win32/i386" pair (of course you need the proper fpc units for both pairs).
I also put the "Target file name" to "something-$(TargetOS)" and the
"Unit output directory" to "units\$(TargetCPU)-$(TargetOS)" so I can see what files are what.

Whichever your compiled executable is (Win32 or Win64), you need to load the proper 32 or 64bit LibMySQL.dll for it. The MySQL database itself does not matter whether 32 or 64bit, both the 32bit/64bit DLL can access them. It is only that your application must load the proper dll for itself. If the application is 32bit then the dll must be 32bit also, same for 64bit.

I'm personally using the latest ZEOS 7.0beta for this and there is an ifdef in my code for 64bit:
Code: [Select]
{$IFDEF WIN64}
     SQLConnection.LibraryLocation := '\blahblah_full_path\libmysql.dll'; //64bit mysql dll
{$ENDIF}
This way, there is no confusion which one is loaded.
The DLL itself I got (just the dll from it) from MySQL-5.5.28-winx64.zip which I downloaded from the MySQL website.
Honestly, I do not have a problem with different MySQL dll versions, I was using an old 32bit one for many years to connect to my server via tcp/ip with my 32bit applications and multiple times the server was updated to a newer MySQL version by the distribution.
« Last Edit: December 14, 2012, 07:34:55 pm by bobo »

psychojock

  • New member
  • *
  • Posts: 8
Re: Windows 7 and MySQL Nightmare!!
« Reply #6 on: December 17, 2012, 01:51:26 pm »
Thanks Bug Chimp & Bobo,
I'll download the dll from MySQL site in the next couple of days and give it a shot.
I'll let you know how I get on!!  ::)

Nix

  • Newbie
  • Posts: 5
    • Waze Srbija
Re: Windows 7 and MySQL Nightmare!!
« Reply #7 on: December 25, 2012, 05:24:56 pm »
Common issue with MySQL :)

Obtain libmysql via the official MySQL download page, and get "non-install" package.

Extract the libmysql.dll to the following path:
Code: [Select]
C:\Windows\SysWOW64
and the problem will fly away :)

Cheers
In scientia veritas, in arte honestas :)

 

TinyPortal © 2005-2018