SQLite Forum

Compiling sqlite system on Ubuntu
Login

Compiling sqlite system on Ubuntu

(1) By jose isaias cabrera (jicman) on 2021-10-12 03:04:18 [link]

Greetings.

I installed SQLite using APT, but the version is last year's.  I am trying to build sqlite 3.36.0, and I tried a few options, including this command,

```
sudo gcc shell.c sqlite3.c -lpthread -ldl -lm
```

but all I get is the a.out file. I am not getting what I want.  I know I am missing some options to get the .so libraries installed, as well as the sqlite3 tool, so, if anyone can help, I would greatly appreciated.

The last thing I did was was run ./configure and make, after downloading the sqlite-autoconf-3360000.tar.gz. And it appears as if everything goes well, but when I do 'which sqlite3', there is no output. Any help would be greatly appreciated. Thanks.

josé

(2) By Larry Brasfield (larrybr) on 2021-10-12 03:28:33 in reply to 1

> sudo gcc shell.c sqlite3.c -lpthread -ldl -lm

There is no need to use sudo for this.

> but all I get is the a.out file.

The command,<code>
     mv a.out sqlite3
</code>, will rename the executable you got to what you wanted (I suppose.)  Alternatively, replace "gcc" with "gcc -o sqlite3" in that compilation to get what you seem to expect.

> last thing I did was was run ./configure and make, ... but when I do 'which sqlite3', there is no output.

The current directory is typically not among the directories listed in $PATH. Hence, 'which' does not find named executable files that happen to be in the current directory unless the current directory is so listed.  Once you get yourself a properly named 'sqlite3' executable, the final step will be to place it somewhere such that it will be found by the shell (using $PATH) when invoked simply as 'sqlite3'.

(3) By Keith Medcalf (kmedcalf) on 2021-10-12 03:38:44 in reply to 1 [link]

`a.out` is the default name of the output file.  

If you want it named something else, then you specify which file to output to with the -o option.

```
gcc shell.c sqlite3.c -lpthread -ldl -lm -o sqlite3
```

You may then need to make sure that the file `sqlite3` is executable.  If it is not, then `chmod +x sqlite3` to make it executable.

It would probably be easier to just do a full source download and use the ordinary configure/make process.  I would suspect that the generated makefile knows how to do `make install` (but I do not know for sure)

(4) By jose isaias cabrera (jicman) on 2021-10-12 13:18:45 in reply to 3 [link]

Thank you both, Keith and Larry. That's fixed.  Now, what about the rest of these files:

```
jcabrera@selva:~/b/sqlite/sqlite-autoconf-3360000$ ls -l sqlite3*
-rwxrwxr-x 1 jcabrera jcabrera  8880672 Oct 11 22:30 sqlite3
-rw-rw-r-- 1 jcabrera jcabrera     8928 Jun 18 14:52 sqlite3.1
-rw-rw-r-- 1 jcabrera jcabrera  8312766 Jun 18 14:52 sqlite3.c
-rw-rw-r-- 1 jcabrera jcabrera    35437 Jun 18 14:52 sqlite3ext.h
-rw-rw-r-- 1 jcabrera jcabrera   588809 Jun 18 14:52 sqlite3.h
-rw-rw-r-- 1 jcabrera jcabrera      288 Oct 11 22:28 sqlite3.lo
-rw-rw-r-- 1 jcabrera jcabrera 17826344 Oct 11 22:28 sqlite3.o
-rw-r--r-- 1 root     root          286 Oct 11 22:42 sqlite3.pc
-rw-rw-r-- 1 jcabrera jcabrera      267 Jun 18 14:52 sqlite3.pc.in
-rw-rw-r-- 1 jcabrera jcabrera     1992 Jun 18 14:52 sqlite3.rc
-rw-rw-r-- 1 jcabrera jcabrera       78 Jun 18 14:52 sqlite3rc.h
-rw-rw-r-- 1 jcabrera jcabrera  2644408 Oct 11 22:28 sqlite3-shell.o
-rw-rw-r-- 1 jcabrera jcabrera 18056664 Oct 11 22:30 sqlite3-sqlite3.o
jcabrera@selva:~/b/sqlite/sqlite-autoconf-3360000$
```

Where do I place them?  I am going to use python for some scripting and I want to make sure that the latest built libraries are the one it uses. Thanks.

josé

(5) By Kees Nuyt (knu) on 2021-10-12 14:32:44 in reply to 4 [link]

> Where do I place them?

`sudo make install` will place anything that needs to be installed into the proper directories, by default in the `/usr/local` tree, or anywhere else where `./configure --prefix=....` points to.  Run `./configure --help for more info.

> ... python for some scripting and I want to make sure that the latest built libraries are the one it uses.

The sqlite make process will not build or install python modules.

If you want to build that yourself, you are probably best off with Roger Binns' [APSW][1] (Another Python SQLite Wrapper)
 
[1]:https://github.com/rogerbinns/apsw

~~~
-- 
Kind Regards,
Kees Nuyt
~~~

(6) By jose isaias cabrera (jicman) on 2021-10-12 14:58:28 in reply to 5 [link]

>If you want to build that yourself, you are probably best off with Roger Binns' APSW (Another Python SQLite Wrapper)

Thanks, Kees.