SQLite Forum

create sqlite3_analyzer from trunk

create sqlite3_analyzer from trunk

(1) By curmudgeon on 2021-01-28 10:29:53 [link] [source]

I've recently started using ubuntu and I've been practicing gcc by trying to compile the sqlite3.c amalgamation and the sqlite3, sqldiff & sqlite3_analyzer executables from the trunk source code. I've managed it all bar the sqlite3_analyzer. I see a sqlite3_analyzer.c.in file in the tools directory but it's contents don't really give me any clues. Anyone help?

(2) By Richard Hipp (drh) on 2021-01-28 12:36:49 in reply to 1 [link] [source]

So "make sqlite3_analyzer" is not working for you? What error do you get?

(3) By curmudgeon on 2021-01-28 16:33:25 in reply to 2 [link] [source]

Hi Richard, is the Makefile supposed to create the sqlite3_analyzer executable automatically? If so I suspect it's a TCL problem.

I installed TCL using 'sudo apt-get install tcl8.6-dev'.

I've got the trunk files in directory ~/sqlite. I run the following script from that directory

echo "updating trunk ..."
exec > /dev/null
fossil update trunk

It does create sqlite3.c, sqlite3.o & sqlite3 but no sqldiff or sqlite3_analyzer. I get the following messages

updating trunk ...
configure: WARNING: Can't find Tcl configuration definitions
configure: WARNING: *** Without Tcl the regression tests cannot be executed ***
configure: WARNING: *** Consider using --with-tcl=... to define location of Tcl ***
ar: `u' modifier ignored since `D' is the default (see `U')

If I run 'make sqlite3_analyzer' I get

sqlite3_analyzer.c:233072:11: fatal error: tcl.h: No such file or directory
233072 | # include "tcl.h"
       |           ^~~~~~~
compilation terminated.
make: *** [Makefile:1308: sqlite3_analyzer] Error 1

I have spent 2 hours trying to find what I should add to the PATH so tcl can be accessed but I'm none the wiser.

(4.2) By curmudgeon on 2021-01-29 14:35:18 edited from 4.1 in reply to 3 [source]


(5) By curmudgeon on 2021-01-29 14:40:48 in reply to 2 [link] [source]

After reading a thread on stackoverflow I uninstalled tcl8.6 and then did 'sudo apt-get install tcl8.6-dev'. After that I found tclConfig.sh in '/usr/lib/tcl8.6' and added that to my PATH.

I ran this script

echo "updating trunk ..."
exec > /dev/null
fossil update trunk
make sqlite3_analyzer
make sqldiff
make test

with response

updating trunk ...
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')

So all working now :-)

The make test footnote was

SQLite 2021-01-27 19:15:06 9dc7fc9f04d5c14fc436e5ff5b4c06c1969ddde5857ebeb5dccd59b7c748c339
0 errors out of 249944 tests on sp4 Linux 64-bit little-endian
All memory allocations freed - no leaks
Maximum memory usage: 9196992 bytes
Current memory usage: 0 bytes
Number of malloc()  : -1 calls

Sublime stuff Richard. it's a wonder your head doesn't explode. I only started working with linux a couple of months back and if I was forced to eat a sweetie every tine I went off at a tangent I suspect I would've put on 30 stone by now.

(6) By Richard Hipp (drh) on 2021-01-29 14:48:31 in reply to 5 [link] [source]

Perhaps a lot of this can be attributed to TCL not being as popular today as it was years ago. It used to be that every system had TCL installed by default and "make sqlite3_analyzer" would just work.

As for me, I normally download the latest Tcl8.7 source code and built it myself ("./configure && make install") and I've never run into the troubles you describe.

Sorry you had trouble. Glad to hear you got it working.

(7.1) By curmudgeon on 2021-01-30 12:01:40 edited from 7.0 in reply to 6 [link] [source]

I initially thought the 'whereis' command searched all directories so it may have been tclConfig.sh existed under tcl8.6 and installing tcl8.6-dev was unnecessary.

My problems were also compounded by the fact I was accessing ubuntu via win10 WSL. It took days of investigation and a thread on git hub to find out that WSL wasn't picking up on changes to the PATH in /etc/environment and that any changes had to be made in the /etc/profile.d/myenvvars.sh file. I had to create the latter file and add
export PATH=~/sqlite:/usr/lib/tcl8.6:$PATH
and reboot WSL to get those directories on the PATH.

Edit: Going by https://packages.ubuntu.com/
tcl8.6 doesn't have the tclConfig.sh and tcl8.6-dev is needed.

(8) By Rowan Worth (sqweek) on 2021-02-01 01:25:25 in reply to 7.1 [link] [source]

tcl8.6-dev is definitely needed. Many distros these days split software packages up into "files you need to run the software" and "files you need to compile & link code against the software." tclConfig.sh falls in the latter category - tcl works just fine without it until you want to compile something against it.

There's no reason you should need to modify PATH or uninstall the tcl8.6 base package though (tcl8.6-dev depends on it so apt would have reinstalled it straight away).

(9) By curmudgeon on 2021-02-01 11:03:23 in reply to 8 [link] [source]

You're right Rowan. Just checked it.

(10) By Wolfgang Oertl (w.oertl) on 2021-07-28 20:59:31 in reply to 6 [link] [source]

Old thread, but I have an observation to add: when configure is being run with the --disable-tcl argument, the Makefile variables needed to build anything tcl-ish (including sqlite3_analyzer) are not set properly (TCC, LIBTCL). "make sqlite3_analyzer" will therefore fail.

So I think tcl headers and libraries should be looked for even in the presence of --disable-tcl. See the attached patch for how it might work. I hereby declare this patch to be public domain, no strings attached, which I'd gladly repeat in form of an affidavit if you tell me how to do this.

BTW, after running automake, I get errors about the recently added AMALGAMATION_LINE_MACROS.

Index: configure.ac
--- configure.ac
+++ configure.ac
@@ -287,13 +287,11 @@
 # This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG
 # macros in the in the tcl.m4 file of the standard TCL distribution.
 # Those macros could not be used directly since we have to make some
 # minor changes to accomodate systems that do not have TCL installed.
-AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
-      [use_tcl=$enableval],[use_tcl=yes])
-if test "${use_tcl}" = "yes" ; then
   AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval})
   AC_MSG_CHECKING([for Tcl configuration])
     # First check to see if --with-tcl was specified.
     if test x"${with_tclconfig}" != x ; then
@@ -455,15 +453,17 @@
-if test "${use_tcl}" = "no" ; then
+AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]),
+      [tcl_ext=$enableval],[tcl_ext=yes])
+if test "${use_tcl}" = "yes" -a "${tcl_ext}" = "yes"; then
 # Figure out what C libraries are required to compile programs