I am trying to use PostgreSQL as a vector database. And for the same I installed PostgreSQL to my windows system using the instructions provided here.
To install pgvector, I followed the instructions given in this page.
I am trying to complete this setup in a remote machine with Windows Server 2016 OS. PostgreSQL version: 15.3
I was unable to successfully install the pgvector extension.
Upon running the nmake /F Makefile.win
command, I get the following error:
fatal error C1083: Cannot open include file ‘crtdefs.h’: No such file or directory
I tried installing using conda as well. command: conda install -c conda-forge pgvector The error obtained when creating vector extension after installation using conda is as follows:
EDIT 1: Updating the post based on the following question.
Where is the file crtdefs.h on your system? (There could be several of these.) What is the value of the INCLUDE environment variable when cl.exe is called?
crtdefs.h file location: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\include
Earlier I didn't have the INCLUDE env variable added. Now, I added the INCLUDE and LIB environment variables based on certain similar errors (cannot open include/lib file). I had to respectively add include and lib paths from Microsoft Visual studio and Windows Kits. Now upon running the nmake /F Makefile.win
command, I get the following error.
fatal error LNK1104: cannot open file 'vector.dll'
vector.dll file is not present in the cloned pgvector folder.
Any help with regards to completing installation using nmake or resolve the error while creating the vector extension will be greatly appreciated. Thanks!
I have experiencing the same issue when I try to install the vector extension in windows locally and finally get this resolved.
The main reason for this issue is the build C++ environment like all the includes are not setup correct due to local computer did not install Visual Studio (C# dotnet developement) only usually installed the VSCode not the dotnet C#, so it is missing a lot of setup.
To fix this you will need to download the build tools from here: "Build Tools for Visual Studio 2022" https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022
The pgvector repo tell you to setup local env via
Call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
But in some case the installed path could be:
Call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
Once run that successful it will remove all the issue of the missing build include files issue
make sure you run CMD in admin mode as the final install will need to copied the compiled DLL file to postgresql folder which need admin permission
make sure you set the environment for where your postgresql are installed
set "PGROOT=C:\Program Files\PostgreSQL\15"
cd to where your pgvector source code directory
this to compiled the DLL
nmake /F Makefile.win
this to copied the SQL files and DLL to postgresql
nmake /F Makefile.win install
The main mistake is missing the run of env setup:
Call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
Please make sure you have vcvars64.bat file in your build tools
Hope this helps