Firebird Embedded and Lazarus

Forum related to Firebird

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
rkamarowski
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 09.08.2007, 21:54

Firebird Embedded and Lazarus

Post by rkamarowski »

I'm trying to run Firebird Embedded in a Lazarus application.


object ZConnection1: TZConnection
Protocol = 'firebird-2.0'
Database = 'C:\Photography\Software\Lazarus\RAKPHOTODB.FDB'

In design mode, when I set the Connected property to True, I get a message that says 'None of the dynamic libraries can be found: Fbclient20.dll ; FbClient.dll'

Both dll's are in the same directory as the fdb.

What am I missing?

thanks,
bob k.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

A few things, I think...
- Embedded : use the firebirdd-2.0 protocol.
- To make a distinction between client/server version and embedded we advise to call the embedded lib fbclientd20.dll. This way you can mix embedded databases and CS databases without trouble.
- The dll's should be in the same dir as your exe OR in the system path. Beware : when connecting in the IDE your path usually is NOT the path were your project is but where your IDE is.

Mark
Image
rkamarowski
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 09.08.2007, 21:54

Post by rkamarowski »

Thank you Mark. That seems to have done the trick.

bob k.
rkamarowski
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 09.08.2007, 21:54

Post by rkamarowski »

Mark,

Should fbembed.dll be renamed fbclientd20.dll?

bob k.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Yes, you have to rename.

See ZPlainFirebird20 :

Code: Select all

const
  WINDOWS1_DLL_LOCATION   = 'fbclient20.dll';
  WINDOWS1_DLL_LOCATION_EMBEDDED = 'fbclientd20.dll';

  LINUX1_DLL_LOCATION   = 'libfbclient.so.20';
  LINUX1_DLL_LOCATION_EMBEDDED = 'libfbembed.so.20';
  LINUX1_IB_CRYPT_LOCATION = 'libcrypt.so.20';
And ZPlainFirebirdDriver

Code: Select all

const

  WINDOWS2_DLL_LOCATION   = 'fbclient.dll';
  WINDOWS2_DLL_LOCATION_EMBEDDED = 'fbclientd.dll';

  LINUX2_DLL_LOCATION   = 'libfbclient.so';
  LINUX2_DLL_LOCATION_EMBEDDED = 'libfbembed.so';
  LINUX2_IB_CRYPT_LOCATION = 'libcrypt.so';
Finally here's the loading logic in ZPlainFirebird20

Code: Select all

initialization
{$IFNDEF UNIX}
  LibraryLoader := TZFirebirdNativeLibraryLoader.Create(
    [WINDOWS1_DLL_LOCATION
		{$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
    	, WINDOWS2_DLL_LOCATION
		{$ENDIF}
    ]);
  LibraryLoaderEmbedded := TZFirebirdNativeLibraryLoader.Create(
    [WINDOWS1_DLL_LOCATION_EMBEDDED
		{$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
    	,WINDOWS2_DLL_LOCATION_EMBEDDED
		{$ENDIF}
    ]);

{$ELSE}
  {$IFDEF ENABLE_INTERBASE_CRYPT}
  	LibraryLoader := TZFirebirdNativeLibraryLoader.Create(
  	[LINUX1_IB_CRYPT_LOCATION
		{$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
	  	, LINUX2_IB_CRYPT_LOCATION
		{$ENDIF}
	  ],[LINUX1_DLL_LOCATION

		{$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
	  	,LINUX2_DLL_LOCATION
		{$ENDIF}
	  ]);

 		LibraryLoaderEmbedded := TZFirebirdNativeLibraryLoader.Create(
    [LINUX1_IB_CRYPT_LOCATION
		{$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
    	,LINUX2_IB_CRYPT_LOCATION
		{$ENDIF}
    ], [LINUX1_DLL_LOCATION_EMBEDDED
		{$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
    	,LINUX2_DLL_LOCATION_EMBEDDED
		{$ENDIF}
    ]);
  {$ELSE}
  	LibraryLoader := TZFirebirdNativeLibraryLoader.Create(
    [LINUX1_DLL_LOCATION
		{$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
    	,LINUX2_DLL_LOCATION
		{$ENDIF}
    ]);
  	LibraryLoaderEmbedded := TZFirebirdNativeLibraryLoader.Create(
    [LINUX1_DLL_LOCATION_EMBEDDED
		{$IFNDEF FIREBIRD_STRICT_DLL_LOADING}
    	,LINUX2_DLL_LOCATION_EMBEDDED
		{$ENDIF}
    ]);
 	{$ENDIF}
{$ENDIF}
Mark
Image
rkamarowski
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 09.08.2007, 21:54

Post by rkamarowski »

Everything looks as it should, but I'm getting an error:

Execution Paused
Address: $77560F18
Procedure: ntdll!RtIUShortByeSwap
File:

Is this a Lazarus problem?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

That's a difficult question. No idea...

You mean that the zeoslib connection and queries work like expected? If that's true you could try to check this with the Lazarus/Fpc people.

Mark
Image
rkamarowski
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 09.08.2007, 21:54

Post by rkamarowski »

No, I meant all the files looked like your examples. I'm able to connect at design time, but when I try to connect by running the application I'm getting the error.
rkamarowski
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 09.08.2007, 21:54

Post by rkamarowski »

Mark,

As I said before, I can connect in design mode with no problem. If I run the application while connected I get a 'database already being accessed' message. If I disconnect the database and run the application, I'm not getting the connection.

Do you have any ideas?

bob k.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Please use some tool to check exactly which dll's are loaded by which process.
I think two different dll's are loaded. My 'thinking path' :
- Lazarus : loads the right one.
- Lazarus + runtime ('already used' scenario) : Lazarus' dll = OK and accesses DB. Runtime's dll = wrong version and can't access the lib as it's an other file.
- Runtime : wrong dll.

If this isn't the problem, I have no idea. My FB experience is quite limited.

Mark
Image
rkamarowski
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 09.08.2007, 21:54

Post by rkamarowski »

Mark,

I think I'm getting closer.

I assume the fdb file gets embedded into the executable (correct)? If so, how is it included?

bob k.
rkamarowski
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 09.08.2007, 21:54

Post by rkamarowski »

Please see attached file.
You do not have the required permissions to view the files attached to this post.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

- No, the file is not included into the executable. You'll have your exe, dll, fdb and some other files (eg. firebird.msg) that have to be available at runtime. So you'll always have the possibility to copy your data file or replace it by an other one. Even upgrading the dll is possible without recompiling your program. What firebird specific files you need you'll have to check with fb docs.
- Is it possible there's need for authentication for the database file? Did you make the database yourself using default values? Try sysdba/masterkey as user/password.

Mark
Image
rkamarowski
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 09.08.2007, 21:54

Post by rkamarowski »

The user/password was the problem.

Thank you Mark.
Post Reply