SQLite Forum

Nit newly exposed in "How to Compile"
Login

Nit newly exposed in "How to Compile"

(1) By Larry Brasfield (LarryBrasfield) on 2021-01-06 20:36:44 [link]

At [Compiling The Command-Line Interface](https://sqlite.org/howtocompile.html#cli), the example given as a "command to compile a full-featured shell" does not quite work because there is a call to the log() function within the fts5Bm25GetData() function which creates an unsatisfied reference at link time. I propose this change:<code>
  gcc -Os -I. -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 \\
 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS \\
 -DHAVE_USLEEP -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DHAVE_READLINE=1 \\
 shell.c sqlite3.c -ldl -lreadline -lncurses -lm -o sqlite3
</code> which builds a CLI shell closer to "full-featured" and cures the missing math library problem.

(2) By Kevin Youren (KevinYouren) on 2021-01-09 19:12:26 in reply to 1

Larry, this an interesting flowon from Dan's update of Full Text Search, which occurred a while ago.

Add "-lm" wherever -DSQLITE_ENABLE_FTS appears? 

I also had to manually add the link to the maths library. 

So, can the documentation be more closely linked to the "code"?

(3.1) By Kevin Youren (KevinYouren) on 2021-01-11 09:30:15 edited from 3.0 in reply to 1 [link]

Deleted

(4) By Larry Brasfield (LarryBrasfield) on 2021-01-10 00:36:34 in reply to 2 [link]

To the extent that compile-and-link example is documentation, your "-lm" addition is part of what I have suggested.  The rest is to add a preprocessor definition to also compile the recently added math functions (-DSQLITE_ENABLE_MATH_FUNCTIONS=1), better reflecting the advertised "command to compile a full-featured shell".

(5) By Kevin Youren (KevinYouren) on 2021-01-10 23:39:41 in reply to 4 [link]

Thanks, Larry.

I'll add the (PRAGMA??) -DSQLITE_ENABLE_MATH_FUNCTIONS=1 to my compile and link, as  well.

I used to download the amalgamation from https://www.sqlite.com/download.html, unpack, and compile and link, and then copy to /usr/local/bin/sqlite3.

Now, I do a 'fossil pull' into my clone of sqlite, followed by:

./configure
make 

I'll get there. Linux is easy, for me.

(6) By Kevin Youren (KevinYouren) on 2021-01-11 09:29:28 in reply to 5 [link]

Larry, 

I checked my clone compile & link from a few days ago. 

-lm & MATH_FUNCTIONS=1 already present. 'Tis somewhat verbose. 

./libtool --mode=compile --tag=CC gcc -g -O2 -DSQLITE_OS_UNIX=1 -I. -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/src -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/rtree -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/icu -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/fts3 -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/async -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/session -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/userauth -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -I/usr/include/tcl8.6 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_MATH_FUNCTIONS  -DSQLITE_HAVE_ZLIB=1  -DSQLITE_TEMP_STORE=1 -c sqlite3.c
libtool: compile:  gcc -g -O2 -DSQLITE_OS_UNIX=1 -I. -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/src -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/rtree -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/icu -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/fts3 -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/async -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/session -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/userauth -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -I/usr/include/tcl8.6 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_HAVE_ZLIB=1 -DSQLITE_TEMP_STORE=1 -c sqlite3.c  -fPIC -DPIC -o .libs/sqlite3.o
libtool: compile:  gcc -g -O2 -DSQLITE_OS_UNIX=1 -I. -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/src -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/rtree -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/icu -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/fts3 -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/async -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/session -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/userauth -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -I/usr/include/tcl8.6 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_HAVE_ZLIB=1 -DSQLITE_TEMP_STORE=1 -c sqlite3.c -o sqlite3.o >/dev/null 2>&1
./libtool --mode=link gcc -g -O2 -DSQLITE_OS_UNIX=1 -I. -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/src -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/rtree -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/icu -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/fts3 -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/async -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/session -I/media/kevin/KCY_Samsung_T5/KCYPrograms/myclone_of_sqlite/ext/userauth -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -I/usr/include/tcl8.6 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_MATH_FUNCTIONS  -DSQLITE_HAVE_ZLIB=1    -no-undefined -o libsqlite3.la sqlite3.lo -lm -ldl -lz -lpthread   \
	 -rpath "/usr/local/lib" -version-info "8:6:8"

Here are the sizes, in case you are curious.


523286 -rwxr-xr-x 1 root root 7660448 Jan  4 18:40 sqlite3
kevin@KCYDell:/usr/local/bin$ ls -la *sqlite*
-rwxr-xr-x 1 root root 7660448 Jan  4 18:40 sqlite3
kevin@KCYDell:/usr/local/bin$ cd /usr/local/lib
kevin@KCYDell:/usr/local/lib$ ls -la *sqlite*
-rw-r--r-- 1 root root 12059292 Jan  4 18:40 libsqlite3.a
-rwxr-xr-x 1 root root      963 Jan  4 18:40 libsqlite3.la
lrwxrwxrwx 1 root root       19 Jan  4 18:40 libsqlite3.so -> libsqlite3.so.0.8.6
lrwxrwxrwx 1 root root       19 Jan  4 18:40 libsqlite3.so.0 -> libsqlite3.so.0.8.6
-rwxr-xr-x 1 root root  4994856 Jan  4 18:40 libsqlite3.so.0.8.6



regs, Kev