'How to compile sqlite-1.0.1, which released 18 years ago
I want to study sqlite by reading its source code. I found sqlite-1.0.1 only contained 10,000+ lines code, maybe it is easy to read. But unfortunately, modern gcc cannot compile sqlite-1.0.1.
wget "https://www.sqlite.org/src/tarball/e8521fc1/SQLite-e8521fc1.tar.gz"
tar xzvf SQLite-e8521fc1.tar.gz
mkdir bld && cd bld
../SQLite-e8521fc1/configure --prefix=/opt/sqlite-1.0.1 --with-tcl=no
make
When I issued make
, it reported
gcc -std=c89 -g -O2 -o lemon ../SQLite-e8521fc1/tool/lemon.c
In file included from ../SQLite-e8521fc1/tool/lemon.c:29:
/usr/lib/gcc/i386-redhat-linux/3.4.2/include/varargs.h:4:2: #error "GCC no longer implements <varargs.h>."
/usr/lib/gcc/i386-redhat-linux/3.4.2/include/varargs.h:5:2: #error "Revise your code to use <stdarg.h>."
I tried appending -std=c89
following gcc
in Makefile
, but it did not work.
I specially installed a old Fedora Core release 3 virtual machine to compile SQLite-1.0.1, but it looks like the gcc(gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)) within Fedora 3 is still too modern for the 18 years ago code.
I found a check in which <varargs.h>
was replaced by <stdarg.h>
, and the author said maybe he has used gcc to compile lemon.c
in 1989.
Maybe a very old gcc or Linux (before 2000) can solve this problem, but how can I get that one?
Solution 1:[1]
I have modified the code of sqlite 1.0.1 and can now compile and run successfully on fedora 36 & MacOS 12.3. You can find this code on github. It can be compiled in docker as follows.(Note: You can also use gcc instead of clang)
docker pull fedora:36
docker run -dt --name f36 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined fedora:36
docker exec -it f36 bash
dnf update -y
dnf install -y ncurses git hostname clang diffutils readline-devel tcl-devel gdbm-devel
mkdir ~/src && cd ~/src
git clone https://github.com/ruomeng0x/sqlite.git
cd ~/src/sqlite
git checkout badcc1d968fdb7cf0ff5d89468248468b8329f4e
mkdir ../build && cd ../build
CC=clang CFLAGS="-std=c89" bash ../sqlite/configure
make
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |