Using 32 and 64 bit dll (sqlite3) lazarus / 21-General ---------------------------------------------------------------------- Tharon · 2021-03-29 18:34 I need to read a sqlite3 database in my application, so i tried the SQlite3Comm component. It need an external DLL to work, who can be 32 and 64 bit. My application works on 32 and 64 bit and i need to ship it with both executables in the same folder. So i need to call the 32 bit DLL with the 32 bit exe, and the 64 bit DLL with the 64 bit exe. The problems is both DLLs share the same name, so i can't have them in the same folder of the executable. I've tried to change the code inside sqlite3.inc to load different named DLL but without success, the modifications are ignored. I can even delete the sqlite3.inc and there are no differences. Any way to change that piece of code ? ---------------------------------------------------------------------- WooBean · 2021-03-29 18:48 Hi, if I were you I would change library oryginal names to sqlite3_32.dll and sqlite3_64.dll and change theirs calling in component configuration. It is all. WooBean ---------------------------------------------------------------------- sstvmaster · 2021-03-29 18:52 Rename 32bit dll to sqlite3_32.dll and for 64bit to sqlite3_64.dll? And set the filename? EDIT: WooBean was faster. ---------------------------------------------------------------------- Tharon · 2021-03-29 18:56 Quote from: WooBean on March 29, 2021, 08:48:40 pmHi, if I were you I would change library oryginal names to sqlite3_32.dll and sqlite3_64.dll and change theirs calling in component configuration. It is all. That's exactly what i did, but it isn't working. At least changing the code. What you mean about component configuration ? ---------------------------------------------------------------------- Tharon · 2021-03-29 18:56 Quote from: sstvmaster on March 29, 2021, 08:52:06 pmRename 32bit dll to sqlite3_32.dll and for 64bit to sqlite3_64.dll? And set the filename? Can't find any way to set it.... ---------------------------------------------------------------------- 440bx · 2021-03-29 19:00 Quote from: Tharon on March 29, 2021, 08:56:48 pmCan't find any way to set it.... From the command line "rename " It will fail if the DLL is currently in use.  In that case, end the program that is using it and issue the command again. ---------------------------------------------------------------------- Tharon · 2021-03-29 19:07 Quote from: 440bx on March 29, 2021, 09:00:59 pmQuote from: Tharon on March 29, 2021, 08:56:48 pmCan't find any way to set it.... From the command line "rename " It will fail if the DLL is currently in use.  In that case, end the program that is using it and issue the command again. Of course i know how to change the name of the DLL  I don't know how to make the component see the new filename instead of the old..... ---------------------------------------------------------------------- sstvmaster · 2021-03-29 19:10 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, SQLDBLib, Forms, Controls, Graphics, Dialogs; type   { TForm1 }   TForm1 = class(TForm)    SQLDBLibraryLoader1: TSQLDBLibraryLoader;  // <-- Component Palett "SQLdb", the "books" on the right    procedure FormCreate(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  SQLDBLibraryLoader1.ConnectionType:='SQLite3';  {$IFDEF CPU32}     SQLDBLibraryLoader1.LibraryName:='sqlite3_32.dll';  {$ELSE}     SQLDBLibraryLoader1.LibraryName:='sqlite3_64.dll'  {$ENDIF}end; end. see: https://wiki.freepascal.org/Conditional_compilation/de#Vordefinie rte_Symbole for other, sorry german no english site. ---------------------------------------------------------------------- WooBean · 2021-03-29 19:11 Tharon, I don't use component  TSQLite3Connection, just looked into and I can see that is very limited at configuration - there is no published fields for library location as it is for example in ZEOSLIB but having source code it is possible to find and change it or ... switch to ZEOSLIB. It will take some time to own reasonable control of it (a week?) but it is worth (many databases can be mastered). [Edited]  Simply add to Form component SQLDBLoader and set values as sstvmaster suggested. WooBean ---------------------------------------------------------------------- Tharon · 2021-03-29 19:20 @sstvmaster Already tried that way without success. Tried to set the library with LoadExtension too. The app always tries to load sqlite3.dll Anyway, that's my code. Maybe i'm doing something wrong; Code: [Select]  TForm1 = class(TForm)     DB: TSQLite3Connection;     procedure FormCreate(Sender: TObject);   private   public   end; var   Form1: TForm1; implementation {$R *.lfm} procedure TForm1.FormCreate(Sender: TObject); Var   DBTrans : TSQLTransaction;   DBQuery : TSQLQuery; Begin   DBTrans := TSQLTransaction.Create(DB);   DB.Transaction := DBTrans;   DB.DatabaseName := 'games.db';;   DBQuery := TSQLQuery.Create(nil);   DBQuery.SQL.Text := 'select * from Directories';   DBQuery.Database := DB;   DBQuery.Open;   while not DBQuery.Eof do   begin     ShowMessage('ID: ' + IntToStR(DBQuery.FieldByName('ID').AsInteger) + #13#10 + 'Name: ' + DBQuery.FieldByName('Path').AsString);     DBQuery.Next;   end;   DBQuery.Close;   DB.Close;   DBQuery.Free;   DBTrans.Free;   DB.Free; end; end. ---------------------------------------------------------------------- WooBean · 2021-03-29 19:33 Last chance, try to use full path of library ie. "C:\lazarus\Projects\myApp\sqlite3_32.dll" or "C:\lazarus\Projects\myApp\sqlite3_64.dll". ZEOSLIB uses such an approach when setting library.  WooBean ---------------------------------------------------------------------- sstvmaster · 2021-03-29 19:43 Quote from: Tharon on March 29, 2021, 09:20:40 pm@sstvmaster Already tried that way without success. Tried to set the library with LoadExtension too. The app always tries to load sqlite3.dll You are right, same here. ---------------------------------------------------------------------- Tharon · 2021-03-29 19:51 Using SQDBLibraryLoader worked to load a different named DLL Code: [Select]  SQLDBLibraryLoader1.LibraryName := 'sqlite3_64.dll';   SQLDBLibraryLoader1.Enabled := True; The enabled did the trick! Thanks everyone for the tips.