I'm on Ubuntu and Alpine Linux. I'm using this SQLite binding:
https://github.com/plashenkov/SQLite3-Delphi-FPCExample program:
program dbtest;
{$mode objfpc}{$H+}
uses
SQLite3Wrap;
const
DatabaseFileName = 'x.db';
Schema = 'create table if not exists x (' +
'id integer primary key, ' +
'x varchar' +
')';
InsertSQL = 'insert into x values (NULL, ?)';
var
db: TSQLite3Database;
stmt: TSQLite3Statement;
begin
try
db := TSQLite3Database.create;
db.open(DatabaseFileName);
db.beginTransaction;
db.execute(Schema);
db.commit;
stmt := db.prepare(InsertSQL);
stmt.bindText(1, '42');
db.beginTransaction;
stmt.stepAndReset;
db.commit;
finally
stmt.free;
db.free;
end;
end.
The SQLite binding defines the following:
const
{$IFDEF MSWINDOWS}
sqlite3_lib = 'sqlite3.dll';
{$ENDIF}
{$IFDEF UNIX}
sqlite3_lib = 'sqlite3.so';
{$ENDIF}
{$IFDEF DARWIN}
sqlite3_lib = 'libsqlite3.dylib';
{$ENDIF}
All SQLite functions are declared in similar style:
function sqlite3_libversion: PAnsiChar; cdecl; external sqlite3_lib;
Compile my example program:
% fpc dbtest.pas
fpc dbtest.pas
Free Pascal Compiler version 3.2.0 [2020/07/07] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling dbtest.pas
Linking dbtest
42 lines compiled, 0.2 sec
By default the executable links to the system-provided SQLite shared library:
% ldd dbtest
linux-vdso.so.1 (0x00007ffdad689000)
libsqlite3.so.0 => /lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007ff044862000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff044713000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff0446f0000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff0446ea000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff0444f8000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff0449a4000)
How to tell FPC to link to my self-compiled libsqlite3.so? I want to use my own libsqlite3.so to make sure that the SQLite functionality my program uses is indeed in the shared library the program links to.