Hello,
(my configuration:
- Untunu 18.04
- Lazarus 1.8.5 + FPC 3.0.5 + Firebird IBX 2.3.2 but I think that TIBTransaction has nothing to do with it)I would like to make an application with Firebird 3.0 embedded. I use IBX components.
I have put in the project directory, all the files (these are the files to deliver, and others just in case...) like this:
/home/.../project1/
|-- database.fdb
|-- project1 (application)
|
|
|-- databases.conf
|-- fbintl.conf
|-- fbtrace.conf
|-- firebird.conf
|-- plugins.conf
|-- firebird.msg
|-- @libfbclient.so (symlink "soft" towards @libfbclient.so.2)
|-- @libfbclient.so.2 (symlink "soft" towards libfbclient.so.3.0.3)
|-- libfbclient.so.3.0.3 (true librairy)
|
└--/intl/
| |-- fbintl.conf
| |-- libfbintl.so
|•
|
└--/plugins/
| |-- libEngine12.so
| |-- libfbtrace.so
|•
|
•
I put the following code that opens the connection... :
procedure TfrmMain.btnOpenCnxClick(Sender: TObject);
begin
with IBDatabase1 do begin
DatabaseName:= '/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/database.fdb';
FirebirdLibraryPathName:= '/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/libfbclient.so.3.0.3';
Connected:= true;
end;
IBTransaction1.Active:= true;
IBTable1.Active:= true;
end;
When I launch the program compiled outside Lazarus (by double-clicking on the "project1" executable), the connection opens correctly
. I am happy.
➔ Now, I would like to know exactly which Firebird 3.0 libraries are used by the Project1 application:- fbguard and firebird services are not loaded (the command "top -b -n1 | grep[f]irebird" returns nothing; that's good, because the documentation says about the embedded version, that there is no need for the firebird executable).
- when I issue these commands in succession... :
pidof /home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/project1
and
lsof -p pid_9999_pid|grep mem
... which returns the libraries used by the application project1 (I have circled those that should make the embedded package to be delivered, if I have understood the documentation correctly), I get the list (see file Laz2_usedLibraries.png).
Well, what bothers me, it is that I would like to deliver everything, executable and Firebird libraries, in the same directory where the application will be installed. In other words, I would like to load the libraries that are in /home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1.
➔ To do this, I have made the following changes:- I've added environment variables that are surrounded in the screenshot.
NB: I also created a FBLIB environment variable as indicated in the very complete IBX documentation, but I think TIBTransaction is absolutely not involved. My environment variables are (visible with the bash cmd "printenv"):
LD_LIBRARY_PATH=:/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1:/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/plugins
FIREBIRD=/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1
FBLIB=/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1- I've modified the file /home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/firebird.conf by adding:
- RootDirectory=/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1
- DatabaseAccess = Full
- ExternalFileAccess = Full
- UdfAccess = Full
- Providers = Engine12
- ServerMode = Classic
- I've renamed the directory /usr/lib/x86_64-linux-gnu/firebird/
3.0/... to /usr/lib/x86_64-linux-gnu/firebird/
6.0/... hoping to force to specifically load the libraries that are in my application directory. But when I launch the application (always at the run-time), I get the following results:
==> the connection refuses to be established at run-time.The only library loaded by the application is /home/guepard/SauveWine_etc/a_projectLaz/dir_project_num1/libfbclient.so.3.3. That's all
.
==>The libraries /usr/.../3.0/plugins/libfbtrace.so, /usr/.../3.0/plugins/libfengine12.so (!!?), and /usr/.../3.0/intl/libfbintl.so are not loaded .Already here, I'm surprised that the environment variables I have added (variables that are supposed to indicate where Firebird libraries are, especially for those needed for an "embedded" mode) do not allow to load these *.SOs (including /home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/plugins/libengine12.so)?!!
➔ So, I've added code to dynamically load them, just before the IBX's connection attempt:uses dynlibs;
.../...
procedure TfrmMain.btnOpenCnxClick(Sender: TObject);
const csPathLibraryLocation_Firebird3_1 = '/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/plugins/libEngine12.so';
csPathLibraryLocation_Firebird3_2 = '/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/plugins/libfbtrace.so';
csPathLibraryLocation_Firebird3_3 = '/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/intl/libfbintl.so';
var
sExceptionMsg: string;
hDLL_Firebird3_1, hDLL_Firebird3_2, hDLL_Firebird3_3: TLibHandle;
ptrDB: Pointer;
iDLL_Func_res: integer;
begin
hDLL_Firebird3_1:= NilHandle; hDLL_Firebird3_2:= NilHandle; hDLL_Firebird3_3:= NilHandle;
hDLL_Firebird3_1:= SafeLoadLibrary(csPathLibraryLocation_Firebird3_1);
if (hDLL_Firebird3_1 = dynlibs.NilHandle) then begin
sExceptionMsg:= 'Library ' + csPathLibraryLocation_Firebird3_1 + 'not launched!';
raise Exception.Create(sExceptionMsg)
end;
hDLL_Firebird3_2:= SafeLoadLibrary(csPathLibraryLocation_Firebird3_2);
if (hDLL_Firebird3_2 = dynlibs.NilHandle) then begin
sExceptionMsg:= 'Library ' + csPathLibraryLocation_Firebird3_2 + 'not launched!';
raise Exception.Create(sExceptionMsg)
end;
hDLL_Firebird3_3:= SafeLoadLibrary(csPathLibraryLocation_Firebird3_3);
if (hDLL_Firebird3_3 = dynlibs.NilHandle) then begin
sExceptionMsg:= 'Library ' + csPathLibraryLocation_Firebird3_3 + 'not launched!';
raise Exception.Create(sExceptionMsg)
end;
with IBDatabase1 do begin
DatabaseName:= '/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/database.fdb';
FirebirdLibraryPathName:= '/home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/libfbclient.so.3.0.3';
Connected:= true;
end;
IBTransaction1.Active:= true;
IBTable1.Active:= true;
end;
==> Same disappointing result (Exception) when I click on the button to open the connection...... yet, the libraries are well loaded from my directory (!!?): see file Laz7_loaded_libraries.png.==> What am I doing wrong? Does anyone see, have an idea, how I am hurting to not succeed in loading libEngine12.so in a "canonical" way and that is functional in order to establish a real embedded connection worthy of the name, from /home/guepard/SauveWinE_etc/a_projetsLaz/dir_project_num1/plugins/libEngine12.so (an embedded installation should allow this, and simplify \ lighten the creation of an installation package)?
Regards.