Firebird 4 embed - error when turning on Connected in IBConnection1 properties. lazarus / 16-Databases ---------------------------------------------------------------------- Jiří Huňáček · 2023-08-19 14:51 Hello to everybody, I'm having trouble turning on the Connected feature when using Firebird 4.0.3 (x64) embedded. I copied all the necessary files according to the instructions (Figure 1). When I only use the property setting in the FormCreate method, the database connects to Firebird embedded without any error. But when I instead want to switch the Connected property to true in the object inspector and all other properties are set the same as in FormCreate, it always tells me that it can't find the Firebird library (Figure 2). I am also attaching a test project. Necessary embedded files here http s://drive.google.com/file/d/1PX0yB0Vgn3GFoB3BPZzP6lbrcgTrX3Nz/view?usp =sharing. Thanks for your replay George ---------------------------------------------------------------------- korba812 · 2023-08-19 15:00 If you want to use Firebird connection at design time then you should also put Firebird libraries in directory where Lazarus IDE executable file is located. ---------------------------------------------------------------------- johnsg · 2023-10-24 18:43 The Firebird website shows FB2.5 as 'discontinued'. FB3 and 4 are current and FB5 is under development. But the only IBConnection component  is hard coded to Firebird 2.5.1., and appears to accept only those libraries.  Short of hand coding a generic SQLConnection for FB3/4, how are you getting a connection to them?  If there is a shortcut it would be useful.  For that matter, could you expand a little on your explanation? thanks JG ---------------------------------------------------------------------- korba812 · 2023-10-24 19:23 You can point to library file using the InitialiseIBase60 function from the ibase60dyn unit. However, you must do this before using components from SQLDB package (for example, at the beginning of your program). It should work with FB4 but I don't know if SQLDB supports all new data types. ---------------------------------------------------------------------- rvk · 2023-10-24 19:30 With TIBConnection there is no need to set the library name. There is also no difference in library name between 2.5, 3 and 4 version of FB. It should just work with any version. https://www.freepascal.org/docs- html/fcl/ibconnection/tibconnection.html So what exactly is the problem? ---------------------------------------------------------------------- korba812 · 2023-10-24 19:49 On Linux platform, name of library file may contain a suffix with version number. Looking at code of ibase60 module, you can see hard- coded library names with version 2.5.1. This is probably what the OP is referring to. ---------------------------------------------------------------------- rvk · 2023-10-24 20:06 Quote from: korba812 on October 24, 2023, 09:49:54 pmOn Linux platform, name of library file may contain a suffix with version number. Looking at code of ibase60 module, you can see hard-coded library names with version 2.5.1. This is probably what the OP is referring to. On Linux the client will also try to load libfc which contains libfbclient.so without version. See https://gitlab.com/freepascal.org/fpc/source/- /blob/main/packages/ibase/src/ibase60.inc?ref_type=heads And a FB client install will always create a symlink for that to the correct version. So this should even work for FB 4 client without problems. But without more information it is hard to say what exactly the problem is. ---------------------------------------------------------------------- johnsg · 2023-10-24 23:58 Problem is no longer reproducable. Source was wiped for fresh start.  Which worked.  Early fumbling with connection strings may have gummed things up.  Problem presented as an error box complaining it coundn't find the v2.5.1 library.  But this was a machine with only FB4.  Backtracking thru the source gets to the ibase60 code which is hard wired to 2.5.1. BUT.  There we have a lot what of fixes that are really workarounds; not suitable for non-expert users of FPC/Laz.  Let alone the insides of Firebird.  And the only IBConnectin component is locked to 2.5.1.  Can't we apply the visual prgmg paradigm to picking the applicble version of FB?  Thanks again JG ---------------------------------------------------------------------- Handoko · 2023-10-25 02:46 It works on my test on Ubuntu Mate 23.04 Lazarus 2.2.6 using Firebird 4 Embedded. There are 3 things need to be done to make the code posted in the first post to work: 1. Linux use '/' as directory separator. So in line #40, that should be: IBConnection1.DatabaseName := ExtractFileDir(ParamStr(0)) + '/DATABASE-v4.FDB'; 2. Add FIREBIRD and LD_LIBRARY_PATH variables to point to the location of the embedded library (or the program binary location, which is shown by ParamStr(0)). Lazarus main menu > Run Parameters > Environment > Add 3. Copy necessaries files to the program binary location. It may also work if you put those files in a separate location, see #2 but I haven't tried. If anyone want to learn more on how to make Firebird Embedded to work on Linux please read rvk's posts: https://forum.lazarus.freepascal.org/index.php/topic,63142.msg477919/t opicseen.html#new In my opinion, Firebird embedded is not for newbies. For making it newbie friendly, someone please write a wiki page explaining how to do it correctly. Also, as far as I know any distribution of Firebird library must also keep IDPLicense.txt and IPLicense.txt intact: Quote3.5. Required Notices.  You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. ---------------------------------------------------------------------- rvk · 2023-10-25 03:04 Quote from: johnsg on October 25, 2023, 01:58:53 amAnd the only IBConnectin component is locked to 2.5.1.  Can't we apply the visual prgmg paradigm to picking the applicble version of FB?  It's not locked to 2.5.1. (and the fact it works now proves that) Please note that it is only the error message that says 2.5.1. It actually also searches for libfbclient.so.2 and libfbclient.so too. And the last one should be present for Firebird 4 (and 5). So it's only the error message which should be fixed. And in my opinion the searching for libfbclient.so.2.5 and libfbclient.so.2 should be removed in favor of just using libfbclient.so and displaying that if it can't be found. There should always be a symlink to the correct library. Otherwise you are always chasing new version. Adding a version option in the component is also not advisable because then your executable can only run with that fb version. Using the symlink it can work with multiple fb versions (if you don't use specific version features.) ---------------------------------------------------------------------- MAndreato · 2024-03-24 11:31 Hi, I share my experience on using embedded Firebird 5 in a Lazarus application (Window 10). I hope this could helps, maybe it could be even more useful to update the https://wiki.freepascal.org/Firebird. Download Firebird kit from https://firebirdsql.org/. I used "Firebird-5.0.0.1306-0-windows-x64.zip" for this testcase. Create a new Lazarus project and in its folder extract the following files/folders from the zip: /intl/pluginsfbclient.dllfirebird.conffirebird.msgib_util.dllicu*.*msv cp140.dllvcruntime140.dllEMPLOYEE.FDB <-- sample database to use in the application (path in the zip: /examples/empbuild/)In the Lazarus project, add the following components: IBConnection1SQLTransaction1 --> set its Database property to IBConnection1SQLQuery1 --> set its Transaction property to SQLTransaction1DataSource1 --> set its DataSet property to SQLQuery1DBGrid1 --> set its DataSource property to DataSource1 and adjust it to the formAdd also Button1 and populate its OnClick event with the following code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);begin  IBConnection1.HostName:= '';  IBConnection1.UserName:= 'SYSDBA';  IBConnection1.Password:= 'masterkey';  IBConnection1.DatabaseName:= ExtractFileDir(ParamStr(0)) + '\EMPLOYEE.FDB';  IBConnection1.Connected:= True;  SQLQuery1.SQL.Text:= 'select RDB$Relation_Name from RDB$RELATIONS where RDB$Relation_Name not like ''%$%''';  SQLQuery1.Open;end; That's all: press F9 to compile+run the application and then press Button1 --> the grid should connect to EMPLOYEE.FDB through the embedded engine and list all its tables (this is obviously just a small proof of concept). ---------------------------------------------------------------------- Handoko · 2024-03-24 11:57 Thank you for sharing your experience on using embedded Firebird 5 in Lazarus for Windows 10. Very useful. I bookmarked this page, I'm sure I will need this information in the future.