Building sqlite-vss from source
If there isn't a prebuilt sqlite-vss build for your operating system or CPU architecture, you can try building sqlite-vss yourself. It'll require a C++ compiler, cmake, and possibly a few other libraries to build correctly.
Below are the general steps to build sqlite-vss. Your operating system may require a few more libraries or setup instructions, so some tips are listed below under Platform-specific compiling tips.
Instructions
To start, clone this repository and its submodules.
git clone --recurse-submodules https://github.com/asg017/sqlite-vss.git
cd sqlite-vssNext, you'll need to build a vendored version of SQLite under vendor/sqlite. To retrieve the SQLite amalgammation, run the ./vendor/get_sqlite.sh script:
./vendor/get_sqlite.shThen navigate to the newly built vendor/sqlite directory and build the SQLite library.
cd vendor/sqlite
./configure && makeNow that all dependencies are downloaded and configured, you can build the sqlite-vss extension! Run either make loadable to build a loadable SQLite extension.
# Build a debug version of `sqlite-vss`.
# Faster to compile, slower at runtime
make loadableAfter it finishes, you'll find debug version of vector0 and vss0 inside dist/debug, with file extensions .dylib, .so, or .dll, depending on your operating system.
To compile static library files of sqlite-vss and sqlite-vector, run make static.
# Build a debug static archive files of `sqlite-vss`, ".a" and ".h" files
make staticAfter it completes, you'll find .a and .h files inside dist/debug, which can be used to statically link sqlite-vss into other projects. The Rust bindings and Go bindings uses this approach.
-I./dist/debug -lsqlite_vector0 -lsqlite_vss0 -llfaiss_avx2For better runtime performance and smaller binaries, consider instead make loadable-release and make static-release.
# Build a release version of `sqlite-vss`.
# Slower to compile, but faster at runtime
make loadable-release
make static-releaseYou'll file the optimized loadable and static files under dist/release.
Platform-specific compiling tips
MacOS (x86_64)
On Macs, you may need to install and use llvm and libomp for compilation. It can be install with brew:
brew install llvm libompAdditionally, if you see other cryptic compiling errors, you may need to explicitly state to use the llvm compilers, with flags like so:
export CC=/usr/local/opt/llvm/bin/clang
export CXX=/usr/local/opt/llvm/bin/clang++
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"If you come across any problems, please file an issue!
MacOS (M1/M2 ARM)
For Mac M1/M2 computers, you'll need llvm and libomp:
brew install llvm libompYou will also likely need the following compiler flags:
export CC="/opt/homebrew/opt/llvm/bin/clang"
export CXX="/opt/homebrew/opt/llvm/bin/clang++"
export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"Note that these are slightly different than the ones above, as LDFLAGS/CPPFLAGS are referencing libomp instead.
Linux (x86_64)
You most likely will need to install the following libraries before compiling:
sudo apt-get update
sudo apt-get install libgomp1 libatlas-base-dev liblapack-dev libsqlite3-devExplainations for these packages:
libgomp1: OpenMP implementation, for multi-threading. Required by Faisslibatlas-base-dev: Provides a BLAS implementation. Required by Faissliblapack-dev: Provides an LAPACK implementation. Required by Faisslibsqlite3-dev: Provides SQLite headers/static files for dev purposes.