compilation with embarcadero Delphi Community Edition

watery's profile image watery posted 4 years ago in General Permalink

I saw that Embarcadero has a free Delphi compiler - a community edition - available for Windows.

I know nothing about the language (I usually work in Java), but was interested in giving a look around it: can this be compiled with the above-mentioned IDE? If so, can anybody give complete instructions about how to do it? I tried to follow the info in the README, but didn't get very far.

watery's profile image watery posted 3 years ago Permalink

Any hint? Or isn't this possible at all?

ansgar's profile image ansgar posted 3 years ago Permalink

Yes, I used the community edition of Delphi 10.4 myself, so that should work. I have recently updated to v10.4.1 Enterprise, but until now I think there are no breaking changes for 10.4.

The build section in the readme file is the place to start, once you installed Delphi.

watery's profile image watery posted 3 years ago Permalink

I tried downloading the IDE right after your post, and again now, but I still get 10.3.3 from the Embarcadero download page. I don't know if that's because I already downloaded it (the first time was in august), I wrote to them around a month ago, but got no response.

I guess I'll have to wait until 10.4 will be available.

Thanks anyway.

ansgar's profile image ansgar posted 3 years ago Permalink

I'm scratching my head, maybe it was 10.3.3 in the last community edition.

You can still try to load the project using 10.3.3 - maybe you need to tweak here and there.

watery's profile image watery posted 3 years ago Permalink

I tried that before opening this thread, but I don't know anything about Delphi as a language, let alone understand how a whole project is handled inside the IDE.

No problem though, I was just curious to look around, especially the SQL formatting part; I can wait till 10.4 comes out or give it another try when I get more spare time.

jonathanpoulin's profile image jonathanpoulin posted 3 years ago Permalink

I managed to build HeidiSQL using Embarcadero Delphi 10.3.3 Community Edition. So I can confirm it is feasible.

First, you have to follow the Building section on the readme.md here https://github.com/HeidiSQL/HeidiSQL#building. It requires also to install madExcept as explained.

Then, the IMPORTANT part is the following. To make it build without errors using Delphi 10.3.3, you'll have to remove all lines of code that starts with "ImageName = <...>" from *.dfm files. That's because this property was introduced in Delphi 10.4.

The only problem I have right now using Delphi 10.3.3 Community Edition to run HeiSQL project is an access violation error when I try to connect to both my MariaDB and MySQL servers. Maybe Ansgar you have an idea why. I can provide more details as needed. It works as expected with connections to MSSQL, PostgreSQL and SQLite files.

As a side note, on my main development computer, I installed Delphi 10.3.3 Community Edition side-by-side with Delphi 10.4.2 Trial without any problems.

By the way, congrat Ansgar, HeidiSQL is a great tool that helps me a lot with my day-to-day job! :-)

ansgar's profile image ansgar posted 3 years ago Permalink

If you have an access violation, and madExcept activated, you should see the exact file/line location where that happens. Please post that here.

jonathanpoulin's profile image jonathanpoulin posted 3 years ago Permalink

Hello Ansgar,

Here is the content of my saved bugreport.txt file about that error:

date/time          : 2021-06-17, 07:33:27, 655ms
computer name      : BEAMCUT-002
user name          : jpoulin
registered owner   : Beamcut
operating system   : Windows 10 x64 build 19043
system language    : English
system up time     : 16 minutes 32 seconds
program up time    : 5 seconds
processors         : 8x Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
physical memory    : 9147/16226 MB (free/total)
free disk space    : (C:) 27.67 GB
display mode       : 1920x1080, 32 bit
process id         : $26e0
allocated memory   : 99.23 MB
largest free block : 131025.96 GB
executable         : heidisql.exe
exec. date/time    : 2021-06-17 07:32
version            : 11.3.0.0
compiled with      : Delphi 10.3 Rio
madExcept version  : 5.1.1
callstack crc      : $33a526db, $5aaf7098, $5aaf7098
exception number   : 1
exception class    : EAccessViolation
exception message  : Access violation at address 00007FFA357F4BD1 in module 'libmariadb64.dll'. Read of address 0000000000000031.

main thread ($4fbc):
7ffa357f libmariadb64.dll
00bbbdd7 heidisql.exe     dbconnection    2166 +105 TMySQLConnection.SetActive
0104707e heidisql.exe     Main            4256   +7 TMainForm.InitConnection
00ec6527 heidisql.exe     connections      440  +10 Tconnform.btnOpenClick
00eca948 heidisql.exe     connections     1123   +5 Tconnform.ListSessionsNodeDblClick
00967ba6 heidisql.exe     VirtualTrees   20593   +2 TBaseVirtualTree.DoNodeDblClick
0096d602 heidisql.exe     VirtualTrees   22427  +14 TBaseVirtualTree.HandleMouseDblClick
0095efe8 heidisql.exe     VirtualTrees   17444   +5 TBaseVirtualTree.WMLButtonDblClk
0040e952 heidisql.exe     System                    TObject.Dispatch
00977d2e heidisql.exe     VirtualTrees   25795  +19 TBaseVirtualTree.WndProc
006c631a heidisql.exe     Vcl.Controls              TWinControl.MainWndProc
00565393 heidisql.exe     System.Classes            StdWndProc
7ffa8226 USER32.dll                                 DispatchMessageW
008720be heidisql.exe     Vcl.Forms                 TApplication.ProcessMessage
00872133 heidisql.exe     Vcl.Forms                 TApplication.HandleMessage
0086b183 heidisql.exe     Vcl.Forms                 TCustomForm.ShowModal
010380ea heidisql.exe     Main            2300 +103 TMainForm.AfterFormCreate
0108ea66 heidisql.exe     heidisql         100  +37 initialization
7ffa8376 KERNEL32.DLL                               BaseThreadInitThunk
7ffa83d2 ntdll.dll                                  RtlUserThreadStart
jonathanpoulin's profile image jonathanpoulin posted 3 years ago Permalink

Interestingly, if I comment line 2166 in dbconnection.pas file, which is the following:

FLib.mysql_options(FHandle, Integer(MYSQL_OPT_LOCAL_INFILE), PAnsiChar('1'));

I can now connect to my MariaDB server without error.

However, I still get another error for MySQL. The error is the following. HeidiSQL seems to try to find the dll at the wrong place. It should look on the subdir plugins64.

Description

ansgar's profile image ansgar posted 3 years ago Permalink

Well, the "plugins64" folder is named by the installer "plugins". You just need to copy it by hand to a "plugins" folder.

Is it the original libmariadb64.dll?

Did you modify some other code probably?

jonathanpoulin's profile image jonathanpoulin posted 3 years ago Permalink

Ok, perfect about the plugin caching_sha2_password.dll. I created a Plugins dir and copied the file there. It works. I can connect to my MySQL server without the error.

For libmariadb64.dll, yes this is the original untouched file. And, nope, I didn't modified any other code, except the line (that I commented) mentionned above and the "ImageName = <...>" lines as explained on my first message. Maybe the problem I have is because of the versions of MySQL and MariaDB I'm running, which is respectively 8.0.25 and 10.5 (both the latest). There is maybe breaking changes related to the line below. Just a guess.

FLib.mysql_options(FHandle, Integer(MYSQL_OPT_LOCAL_INFILE), PAnsiChar('1'));

watery's profile image watery posted 3 years ago Permalink

I managed to build HeidiSQL using Embarcadero Delphi 10.3.3 Community Edition. So I can confirm it is feasible.

First, you have to follow the Building section on the readme.md here https://github.com/HeidiSQL/HeidiSQL#building. It requires also to install madExcept as explained.

Then, the IMPORTANT part is the following. To make it build without errors using Delphi 10.3.3, you'll have to remove all lines of code that starts with "ImageName = <...>" from *.dfm files. That's because this property was introduced in Delphi 10.4.

The only problem I have right now using Delphi 10.3.3 Community Edition to run HeiSQL project is an access violation error when I try to connect to both my MariaDB and MySQL servers. Maybe Ansgar you have an idea why. I can provide more details as needed. It works as expected with connections to MSSQL, PostgreSQL and SQLite files.

As a side note, on my main development computer, I installed Delphi 10.3.3 Community Edition side-by-side with Delphi 10.4.2 Trial without any problems.

By the way, congrat Ansgar, HeidiSQL is a great tool that helps me a lot with my day-to-day job! :-)

Hey!, Cool, thanks!

I'm gonna try your instructions as soon as possible.

jonathanpoulin's profile image jonathanpoulin posted 3 years ago Permalink

I managed to build HeidiSQL using Embarcadero Delphi 10.3.3 Community Edition. So I can confirm it is feasible.

First, you have to follow the Building section on the readme.md here https://github.com/HeidiSQL/HeidiSQL#building. It requires also to install madExcept as explained.

Then, the IMPORTANT part is the following. To make it build without errors using Delphi 10.3.3, you'll have to remove all lines of code that starts with "ImageName = <...>" from *.dfm files. That's because this property was introduced in Delphi 10.4.

The only problem I have right now using Delphi 10.3.3 Community Edition to run HeiSQL project is an access violation error when I try to connect to both my MariaDB and MySQL servers. Maybe Ansgar you have an idea why. I can provide more details as needed. It works as expected with connections to MSSQL, PostgreSQL and SQLite files.

As a side note, on my main development computer, I installed Delphi 10.3.3 Community Edition side-by-side with Delphi 10.4.2 Trial without any problems.

By the way, congrat Ansgar, HeidiSQL is a great tool that helps me a lot with my day-to-day job! :-)

Hey!, Cool, thanks!

I'm gonna try your instructions as soon as possible.

Happy to help on this one, even if it was 9 months old.

messi's profile image messi posted 3 years ago Permalink

The access violation just exposes a subtle bug in that line of code:

exception message : Access violation at address 00007FFA357F4BD1 in module 'libmariadb64.dll'. Read of address 0000000000000031.

The address matches the code point of '1', which is a Char literal and not a string. PAnsiChar('1') is equivalent to PAnsiChar($31), so a pointer to address $31. First ensuring it's a string would make it a pointer to the null-terminated string, what looks like it was the intention.

Looking at the 2 cases of PAnsiChar('1') in dbconnection.pas, the function is not expecting a pointer to a null-terminated string according to the MySQL doc for mysql_options:

  • for MYSQL_ENABLE_CLEARTEXT_PLUGIN: pointer to bool
  • for MYSQL_OPT_LOCAL_INFILE: pointer to unsigned int

Using PAnsiChar(@CardinalWithNonZeroValue) would probably work reliably for both.

Side note: address $31 should never be valid, so it's a bit surprising this doesn't crash consistently. My best guess is that some versions of libmariadb try to detect bad pointers and silently deal with it, while others don't and crash.

Please login to leave a reply, or register at first.