Page 1 of 1
Firebird Embedded and Lazarus
Posted: 23.05.2008, 15:59
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.
Posted: 23.05.2008, 20:32
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
Posted: 24.05.2008, 16:13
by rkamarowski
Thank you Mark. That seems to have done the trick.
bob k.
Posted: 29.05.2008, 14:08
by rkamarowski
Mark,
Should fbembed.dll be renamed fbclientd20.dll?
bob k.
Posted: 29.05.2008, 15:28
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
Posted: 29.05.2008, 16:37
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?
Posted: 29.05.2008, 19:32
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
Posted: 29.05.2008, 20:44
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.
Posted: 02.06.2008, 14:26
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.
Posted: 02.06.2008, 15:21
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
Posted: 02.06.2008, 17:17
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.
Posted: 02.06.2008, 19:50
by rkamarowski
Please see attached file.
Posted: 02.06.2008, 21:06
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
Posted: 02.06.2008, 21:24
by rkamarowski
The user/password was the problem.
Thank you Mark.