Discussion:
[fpc-pascal] Cannot use SQLite 64 bit dll
Dennis
2018-10-19 17:22:22 UTC
Permalink
Using Lazarus and FPC and sqlite3conn unit, I can use the sqlite3.dll on
windows without problem.

However, when I try to convert my project to win 64, it just fail
without any warning.

I am using
    FPC 3.1.1 Revision 63034
    Lazarus 1.9.0
    both are Win64

I download the win 64 bit version of sqlite3.dll from
https://www.sqlite.org/2018/sqlite-dll-win64-x64-3250200.zip
and place it in the same folder as my exe.

The project compiles without errors nor warning.

But when I run the exe, it just waits a few seconds and then quits silently.

I tried debugging it and set breakpoints at all of  the following in
sqlite3.inc
function TryInitializeSqlite(const LibraryName: UnicodeString): Integer;
function InitialiseSQLite:integer;
function  InitializeSQLiteANSI(const LibraryName: AnsiString):integer;
function  InitializeSQLite(const LibraryName: UnicodeString) :integer;
function  InitialiseSQLite(const LibraryName: UnicodeString):integer;

and the following in SQLite3Conn:
class function TSQLite3ConnectionDef.DefaultLibraryName: string;
class function TSQLite3ConnectionDef.LoadedLibraryName: string;
class function TSQLite3ConnectionDef.LoadFunction: TLibraryLoadFunction;

However, the debugger did not stop at all at any of them.

What could possibly be the cause of the problem?

Dennis
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo
Sven Barth via fpc-pascal
2018-10-20 11:19:53 UTC
Permalink
Post by Dennis
Using Lazarus and FPC and sqlite3conn unit, I can use the sqlite3.dll
on windows without problem.
However, when I try to convert my project to win 64, it just fail
without any warning.
I am using
    FPC 3.1.1 Revision 63034
    Lazarus 1.9.0
    both are Win64
I download the win 64 bit version of sqlite3.dll from
https://www.sqlite.org/2018/sqlite-dll-win64-x64-3250200.zip
and place it in the same folder as my exe.
The project compiles without errors nor warning.
But when I run the exe, it just waits a few seconds and then quits silently.
I tried debugging it and set breakpoints at all of  the following in
sqlite3.inc
function TryInitializeSqlite(const LibraryName: UnicodeString): Integer;
function InitialiseSQLite:integer;
function  InitializeSQLiteANSI(const LibraryName: AnsiString):integer;
function  InitializeSQLite(const LibraryName: UnicodeString) :integer;
function  InitialiseSQLite(const LibraryName: UnicodeString):integer;
class function TSQLite3ConnectionDef.DefaultLibraryName: string;
class function TSQLite3ConnectionDef.LoadedLibraryName: string;
class function TSQLite3ConnectionDef.LoadFunction: TLibraryLoadFunction;
However, the debugger did not stop at all at any of them.
What could possibly be the cause of the problem?
A simple test here with a SQLite3Connection works without problems.

Do you get an exception if the library is *not* located in the same
folder? In that case it loaded correctly and something else must be the
problem.

Regards,
Sven
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://li
Dennis
2018-10-21 08:32:22 UTC
Permalink
A simple test here with a SQLite3Connection works without problems.
Post by Sven Barth via fpc-pascal
Do you get an exception if the library is *not* located in the same
folder? In that case it loaded correctly and something else must be
the problem.
Regards,
Sven
_______________________________________________
I deleted the library from the exe folder and surprisingly it behaved
exactly the same. it just waited a few seconds before quitting silently.
No except was thrown.
I suspect the exe tries to link to the sqlite dll somewhere in the
search path, which is a 32 bit version, so it quits silently after
finding out it is not a 64 bit dll.

How can I force SQLite3Connection to first look for the dll in the exe
folder instead of from the search path?

Dennis
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinf
Michael Van Canneyt
2018-10-21 08:36:06 UTC
Permalink
Post by Sven Barth via fpc-pascal
A simple test here with a SQLite3Connection works without problems.
Post by Sven Barth via fpc-pascal
Do you get an exception if the library is *not* located in the same
folder? In that case it loaded correctly and something else must be
the problem.
Regards,
Sven
_______________________________________________
I deleted the library from the exe folder and surprisingly it behaved
exactly the same. it just waited a few seconds before quitting silently.
No except was thrown.
I suspect the exe tries to link to the sqlite dll somewhere in the
search path, which is a 32 bit version, so it quits silently after
finding out it is not a 64 bit dll.
How can I force SQLite3Connection to first look for the dll in the exe
folder instead of from the search path?
That should be the case automatically.

You can also use a TSQLDBLibraryLoader component to specify the library location
exactly. If you use lazarus, it's on the component palette.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/c

Loading...