Recent

Author Topic: Firebird 4 embed - error when turning on Connected in IBConnection1 properties.  (Read 1673 times)

Jiří Huňáček

  • New Member
  • *
  • Posts: 14
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 https://drive.google.com/file/d/1PX0yB0Vgn3GFoB3BPZzP6lbrcgTrX3Nz/view?usp=sharing.

Thanks for your replay

George
« Last Edit: August 19, 2023, 04:58:34 pm by Jiří Huňáček »
Best regards / mit freundlichen Grüßen / s pozdravem
Jiří Huňáček (George)

korba812

  • Sr. Member
  • ****
  • Posts: 377
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

  • Newbie
  • Posts: 2
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

  • Sr. Member
  • ****
  • Posts: 377
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

  • Hero Member
  • *****
  • Posts: 5651
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

  • Sr. Member
  • ****
  • Posts: 377
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

  • Hero Member
  • *****
  • Posts: 5651
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.
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

  • Newbie
  • Posts: 2
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

  • Hero Member
  • *****
  • Posts: 5060
  • My goal: build my own game engine using Lazarus
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/topicseen.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:

Quote
3.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.
« Last Edit: October 25, 2023, 06:00:16 am by Handoko »

rvk

  • Hero Member
  • *****
  • Posts: 5651
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? 
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.)


 

TinyPortal © 2005-2018