7

I'm new to sqlite , I just got the binary of sqlite by using wget http://www.sqlite.org/sqlite-shell-linux-x86-3071300.zip, then extract sqlite3 from the zip file, it does not work, it's driving me crazy, please HELP.

My OS is Ubuntu 12.04 64-bit, the steps of execution of sqlite as follows,

u1@newhost:/tmp$ ls -hl sqli*
-rwxrwxr-x 1 u1 u1 568K Jun 11 17:35 sqlite3
-rw-rw-r-- 1 u1 u1 310K Jun 12 02:53 sqlite-shell-linux-x86-3071300.zip
u1@newhost:/tmp$ file sqlite3
sqlite3: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x8637c6613a485b675a05f155564cc0eda4b2d3cc, stripped
u1@newhost:/tmp$ ./sqlite3 mydb.db
-bash: ./sqlite3: No such file or directory
u1@newhost:/tmp$

For security reason, I removed . from the $PATH, so I just use ./sqlite3 to launch

UPDATE BELOW:

this way works for Fedora 15 32-bit

[root@newhostfedora15 ~]# ./sqlite3 test.db
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .e

this also works on CentOS 5.6 64-bit

BUT DOES NOT work for root on My Ubuntu 12.04 64-bit either,

root@newhost:~# unzip sqlite-shell-linux-x86-3071300.zip
Archive:  sqlite-shell-linux-x86-3071300.zip
  inflating: sqlite3
root@newhost:~# ./sqlite3 f
-bash: ./sqlite3: No such file or directory
root@newhost:~# ldd ./sqlite3
        not a dynamic executable

I got this issue as the result, it works on Ubuntu 12.04 32-bit, CenetOS 5.6 64-bit, DOES NOT WORK on Ubuntu 12.04 64-bit, Fedora 17 64-bit, sqlite's 32-bit binary is great enough although it doesn't work for every platform. I'll keep it in mind that to it is best to compile my own 64-bit binary from the source or it will be awesome if sqlite 64-bit binary is provide through the official web-site :P

vicd
  • 511

1 Answers1

8

With Ubuntu (as well as many other Linux distributions) the preferred method of installing software is to use the package management infrastructure. One tool for package management on Ubuntu is apt-get.

For example, to install sqlite3:

sudo apt-get update
sudo apt-get install sqlite3

this will download the official Ubuntu build of sqlite, and install it on your system. This way, you don't have to deal with the downloading yourself, or debugging problems with incompatible binary versions.

[The first command, sudo apt-get update just downloads the most recent list of packages available. You don't need to do this every time you want to install a package]

Then, you can just run sqlite3:

sqlite3

In case you really want to run the non-packaged sqlite binary, you need to ensure you have all the necessary bits for your machine. The sqlite binary in the archive is a 32-bit dynamically linked executable (as you saw by running file), so we'll at least need a 32-bit dynamic linker, plus any necessary libraries.

For the dynamic linker, we need the i386 build of the libc6 package. You can install this with:

sudo apt-get install libc6:i386

Then, you should be able to run ldd on the binary to show what other libraries it may need. For example, on my system:

[jk@pablo sqlite]$ ldd ./sqlite3 
linux-gate.so.1 =>  (0xf76f1000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf76c1000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf750d000)
/lib/ld-linux.so.2 (0xf76f2000)

Since all of those libraries are present (ldd will report not found if something is missing), we should be fine to run the sqlite3 command.

Jeremy Kerr
  • 27,829