The following builds latest sqlite with dynamic library support, and compiles series extension. It also assumes debian-based linux distributive:
sudo apt build-dep sqlite3
mkdir sqlite-compilation
cd sqlite-compilation
wget -O sqlite.tar.gz https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=release
tar xzf sqlite.tar.gz
mkdir build
cd build
../sqlite/configure
make OPTS='-DSQLITE_ENABLE_LOAD_EXTENSION'
./sqlite3 -cmd 'pragma compile_options;' <<< .exit
cd -
cd sqlite/ext/misc
gcc -g -O2 -shared -fPIC -I ../../../build -o series ./series.c
../../../build/sqlite3 <<< '
.load ./series
select value from generate_series(5,30,5);
.exit
'
cd -
In result you will have:
build/sqlite3 # sqlite3 binary
sqlite/ext/misc/series.so # series extension
Also, if you want change the name of the extension object file (series.so
), you need to edit its init function with a "generic" one:
sed -i 's/int sqlite3_series_init(/int sqlite3_extension_init(/' series.c
gcc -g -O2 -shared -fPIC -I ../../../build -o libSqlite3Series.so ./series.c
sqlite3 <<< '
.load ./libSqlite3Series
select value from generate_series(5,30,5);
.exit
'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…