Recent

Author Topic: MySql with Lazarus  (Read 10428 times)

Handas

  • Newbie
  • Posts: 3
MySql with Lazarus
« on: June 10, 2015, 09:23:10 pm »
Hello,

I was trying it for hours, but i cant find a answer. I hope that u can help me.
I try to connect to an MySql Database with Lazarus.
I use the TMySQL55Connection Component and downloaded the MySql Server 5.5.
The libmysql.ddl is already in my project, System32 and Lazarus directory.
But if i try to connect, i get the error message: "Can not load default MySql Libary ('libmysql.dll' or 'libmysql.dll') Check your installation"

Thanks for helping

rvk

  • Hero Member
  • *****
  • Posts: 4702
Re: MySql with Lazarus
« Reply #1 on: June 10, 2015, 11:10:20 pm »
Is the libmysql.dll the 32bit version or the 64bit version?
It must match your target.exe of your project.

Also... System32 on a 64bit OS is where the 64bit dll's go.
SysWOW64 is where the 32bit dll's go on a 64bit OS.

But it should be sufficient to have them in your project directory (and the Lazarus directory if you want to run it from the IDE).

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: MySql with Lazarus
« Reply #2 on: June 15, 2015, 03:02:32 am »
@Handas:
If you haven't already done it, you should add $(TargetCPU)-$(TargetOS)(one or both) to your out-path.
that way the DLL-files don't mix since they often have the same name. ([Of Topic:] I think this is a M$-design-error)

BTW, Does anyone know how to do it without the DLL's ?
(Since i am a monolith-guy, one file (an EXE) that must do it.)
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

rvk

  • Hero Member
  • *****
  • Posts: 4702
Re: MySql with Lazarus
« Reply #3 on: June 16, 2015, 11:44:37 am »
BTW, Does anyone know how to do it without the DLL's ?
(Since i am a monolith-guy, one file (an EXE) that must do it.)
I'm not aware of an option to use a MySQL server without using the client-library dynamically loaded.

However... here is one example of using the SQLite-client library statically loaded and linked in (although not the MySQL one).
http://forum.lazarus.freepascal.org/index.php/topic,15712.msg84781.html#msg84781
(Maybe it's adaptable for MySQL)

Another option would be to include the DLL as a resource and writing it to disk before using it.

And yet another option would be loading the DLL direct from resource but I've only done this with Delphi once.

taazz

  • Hero Member
  • *****
  • Posts: 5364
Re: MySql with Lazarus
« Reply #4 on: June 16, 2015, 11:54:22 am »
BTW, Does anyone know how to do it without the DLL's ?
(Since i am a monolith-guy, one file (an EXE) that must do it.)
The license that comes along with mysql do not allow you to share the client dlls with your comercial application with out purchasing a commercial license. So unless you want to share the source code of your application I suggest that you stay away of statically linking mysql in to your application. There is a way ofcourse to avoid using the client library if you are dead set on it but it requires that you rewrite its functionality using sockets for communication.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: MySql with Lazarus
« Reply #5 on: July 08, 2015, 12:48:26 am »
The license that comes along with mysql do not allow you to share the client dlls with your comercial application with out purchasing a commercial license. So unless you want to share the source code of your application I suggest that you stay away of statically linking mysql in to your application. There is a way ofcourse to avoid using the client library if you are dead set on it but it requires that you rewrite its functionality using sockets for communication.
I don't talk of statically linking the dll in the exe, I talk of a native client written in pascal. I started something like this for MsSQL, untill the ado-(dbGO) things came out and made my project obsolete.
So before doing something and reinventing the wheel i asked if sombody already had something to go on.
 
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

chrnobel

  • Sr. Member
  • ****
  • Posts: 283
Re: MySql with Lazarus
« Reply #6 on: July 10, 2015, 12:52:49 pm »
I don't talk of statically linking the dll in the exe, I talk of a native client written in pascal. I started something like this for MsSQL, untill the ado-(dbGO) things came out and made my project obsolete.
So before doing something and reinventing the wheel i asked if sombody already had something to go on.
Back in the old days, when programming in Delphi, I used the DAC for MySQL from MicroOLAP - worked really well, and gave the possibility to make a monolithic application, without worrying about whether there was a MySQL client installed on the client computer or not.

Although a developer license from MicroOLAP did cost quite a lot it made licensing much simpler, as I did not have to bother with MySQL licensing when distributing my program. 

This was a huge advantage, and I do really miss something similar in FPC (and it should of course be cross platform), so do anyone know if someone is writing on something like that?

 

TinyPortal © 2005-2018