SQLite3
-
- Posts: 5
- Joined: Aug 27, 2022 7:27
SQLite3
With retirement looming from 50 years of being a software engineer, I wanted to continue as a retirement hobby. I plan on using SQLite3 as the data container for anything I do. I used Microsoft Visual Studio to compile the SQLite3 amalgamation (I'm avoiding DLL's) using:
cl /c /EHsc /O2 /TC sqlite3.c
lib sqlite3.obj
So now, I'm trying to understand the next step to get FB to use either the Lib or Obj files created. How do I do that?
breacsealgaire
cl /c /EHsc /O2 /TC sqlite3.c
lib sqlite3.obj
So now, I'm trying to understand the next step to get FB to use either the Lib or Obj files created. How do I do that?
breacsealgaire
-
- Posts: 5
- Joined: Aug 27, 2022 7:27
Re: SQLite3
After going through forum history, I did the following:
cl /c /EHsc /O2 /TC sqlite3.c
ar rcs -o libsqlite3.a sqlite3.obj
a quick console program:
#Define UNICODE
#Include Once "windows.bi"
#Inclib "libsqlite3"
#ifdef __FB_WIN32__
extern "Windows"
#else
extern "C"
#endif
Function sqlite3_libversion() AS CONST ZSTRING PTR
end function
end Extern
DIM psz as const ZSTRING PTR = sqlite3_libversion()
Print *psz
Print "Press any key..."
Sleep
Compiles fine and linker always fails libsqlite3 not found. I have it both the ..lib folder and with my .bas program.
What am I doing wrong?
cl /c /EHsc /O2 /TC sqlite3.c
ar rcs -o libsqlite3.a sqlite3.obj
a quick console program:
#Define UNICODE
#Include Once "windows.bi"
#Inclib "libsqlite3"
#ifdef __FB_WIN32__
extern "Windows"
#else
extern "C"
#endif
Function sqlite3_libversion() AS CONST ZSTRING PTR
end function
end Extern
DIM psz as const ZSTRING PTR = sqlite3_libversion()
Print *psz
Print "Press any key..."
Sleep
Compiles fine and linker always fails libsqlite3 not found. I have it both the ..lib folder and with my .bas program.
What am I doing wrong?
-
- Posts: 5
- Joined: Aug 27, 2022 7:27
Re: SQLite3
Ok, ok changed to inclib "sqlite3' and now the linker tells me
skipping incompatible ./libsqlite3.a when searching for -lsqlite3
Re: SQLite3
Check the bitness of the library. That error means that you're trying to compile a 64-bit program linking against a 32-bit lib (or vice-versa).breacsealgaire wrote: ↑Aug 28, 2022 6:38Ok, ok changed to inclib "sqlite3' and now the linker tells me
skipping incompatible ./libsqlite3.a when searching for -lsqlite3
Re: SQLite3
My attempt
files in download
shell.c
sqlite3.c
sqlite3.h
sqlite3ext.h
My commands (64 bit gcc)
gcc -c *.c
(got the .o files)
ar rcs -o libsqlite3.a *.o
(got libsqlite3.a)
Test code (in win 10)
result
You can use nm libsqlite.a to track down the functions available.
Not so handy as a dll .def file. but you can double check sqlite3.bi if the occasion arises.
Happy hunting.
files in download
shell.c
sqlite3.c
sqlite3.h
sqlite3ext.h
My commands (64 bit gcc)
gcc -c *.c
(got the .o files)
ar rcs -o libsqlite3.a *.o
(got libsqlite3.a)
Test code (in win 10)
Code: Select all
#inclib "sqlite3"
extern "windows"
declare Function sqlite3_libversion alias "sqlite3_libversion"() AS CONST ZSTRING PTR
end Extern
DIM psz as const ZSTRING PTR = sqlite3_libversion()
Print *psz
Print "Press any key..."
Sleep
Code: Select all
3.39.2
Press any key...
Not so handy as a dll .def file. but you can double check sqlite3.bi if the occasion arises.
Happy hunting.
-
- Posts: 5
- Joined: Aug 27, 2022 7:27
Re: SQLite3
Thanks! Oversight on the compile not including the 64 bit switch due to delayed intelligence.
Now to figure out why the call to sqlite3_libversion is returning a 0 zstring pointer.
-
- Posts: 5
- Joined: Aug 27, 2022 7:27
Re: SQLite3
I was using MS C++ compiler and LIB. Using your declare Function is get undefined reference sqlite3_libversion@0. We'll look into that.dodicat wrote: ↑Aug 28, 2022 21:36 gcc -c *.c
(got the .o files)
ar rcs -o libsqlite3.a *.o
(got libsqlite3.a)
Test code (in win 10)resultCode: Select all
#inclib "sqlite3" extern "windows" declare Function sqlite3_libversion alias "sqlite3_libversion"() AS CONST ZSTRING PTR end Extern DIM psz as const ZSTRING PTR = sqlite3_libversion() Print *psz Print "Press any key..." Sleep
You can use nm libsqlite.a to track down the functions available.Code: Select all
3.39.2 Press any key...
Not so handy as a dll .def file. but you can double check sqlite3.bi if the occasion arises.
Happy hunting.
Trying out gcc -c *.c get lots of missing headers. I'll look at the command line options.
Re: SQLite3
You only need the declaration, not the body.
declare Function sqlite3_libversion() AS CONST ZSTRING PTR
OR using the .bi file and you have libsqlite3.a in the same folder as your code, or in the lib folder of the distribution.
Sorry, I missed your last post.
In my download there were only the four files, two .c and two .h (as shown above).
gcc didn't even give a warning, it went like clockwork.
I have :
gcc version 12.1.0 (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders
Here was my download site:
https://www.sqlite.org/download.html
I used the first .zip on the page.
declare Function sqlite3_libversion() AS CONST ZSTRING PTR
Code: Select all
#inclib "sqlite3"
extern "windows"
declare Function sqlite3_libversion() AS CONST ZSTRING PTR
end Extern
DIM psz as const ZSTRING PTR = sqlite3_libversion()
Print *psz
Print "Press any key..."
Sleep
Code: Select all
#include "sqlite3.bi"
DIM psz as const ZSTRING PTR = sqlite3_libversion()
Print *psz
Print "Press any key..."
Sleep
In my download there were only the four files, two .c and two .h (as shown above).
gcc didn't even give a warning, it went like clockwork.
I have :
gcc version 12.1.0 (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders
Here was my download site:
https://www.sqlite.org/download.html
I used the first .zip on the page.