Compiling sqlite-vec
August 21, 2024
- https://www.mingw-w64.org/
- https://clang.llvm.org/get_started.html
- https://releases.llvm.org/download.html
- https://github.com/asg017/sqlite-vec/issues/13
- https://github.com/asg017/sqlite-vec/releases?page=1
- https://sbert.net/docs/installation.html
Troubleshooting
If using Visual Studio, launch the "x64 Native Tools Command Prompt for VS" or equivalent, and try running the command again.
clang --version
cl --version
Install clang (via Visual Studio):
- Open Visual Studio Installer:
- Modify Your Installation:
- Under the Workloads tab, ensure the "Desktop development with C++" workload is selected.
- Scroll down and select "LLVM/Clang tools for Windows."
- Click Modify to install the Clang tools.
Install clang (via llvm downloads):
- ...
Compiling
git clone [https://github.com/asg017/sqlite-vec](https://github.com/asg017/sqlite-vec)
cd sqlite-vec
make loadable
cl -W -I.\sqlite-autoconf sqlite-vec.c sqlite-vec.h -O2
cl -W -I.\sqlite-autoconf sqlite-vec.c sqlite-vec.h -O2 -fPIC -shared -o vec0.dll
# works
clang-cl.exe /D_USRDLL /D_WINDLL sqlite-vec.c /MT /link /DLL /OUT:sqlite-vec.dll
# doesn't work
cl.exe /D_USRDLL /D_WINDLL sqlite-vec.c /MT /link /DLL /OUT:sqlite-vec.dll
Terminology
Clang:
- Clang is a compiler front end for the C, C++, and Objective-C programming languages.
- It uses the LLVM (Low-Level Virtual Machine) as its back end.
- Known for fast compilation times, clear and concise error messages, and compatibility with GCC (GNU Compiler Collection).
- Used in various development environments, including Apple's Xcode.
- Increasingly popular as a replacement for GCC due to its modular design and better diagnostic tools.
CL (C/C++ Compiler):
- CL is the command-line compiler for C and C++ provided by Microsoft Visual Studio.
- Compiles C and C++ source code into machine code (binary) that can be executed by the computer.
- Part of the Microsoft Build Tools.
- Often invoked by developers working on Windows platforms to compile their code from the command line.
MinGW (Minimalist GNU for Windows):
- MinGW is a minimalist development environment for native Microsoft Windows applications.
- Provides a port of the GCC (GNU Compiler Collection).
- Allows developers to compile and build Windows applications using open-source tools.
- Includes a set of runtime libraries, header files, and a compiler compatible with Windows.
- Enables the creation of native Windows executables without relying on proprietary tools.
DLLs (Dynamic-Link Libraries):
- DLLs are files that contain code and data that can be used by multiple programs simultaneously in the Windows operating system.
- Allow for modularization of code, making it easier to update and reuse code without recompiling programs.
- Essential in Windows for creating shared libraries.
- Different programs can call functions contained in a single DLL, reducing redundancy and saving memory.