1

i have a problem with Pgvector extension installation on Windows

so the code for installation is

set "PGROOT=C:\Program Files\PostgreSQL\15"
git clone --branch v0.4.2 https://github.com/pgvector/pgvector.git
cd pgvector
nmake /F Makefile.win
nmake /F Makefile.win install

and i am getting fatal error:

C:\Program Files\pgvector>nmake /F Makefile.win

C:\Program Files\PostgreSQL\15\lib\postgres.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86' vector.dll : fatal error LNK1120: 109 unresolved externals

and i get bunch of LNK 2001 & 2019 errors apart from these.

i'm using; MSVC v143 package Windows universal CRT SDK Windows 10 SDK

Vandalism
  • 23
  • 4

1 Answers1

2

I'm not expert in compiling at all but I manage to do it. Here is how I did it:

  • firstly you can't run nmake directly from the command prompt tool: NMAKE : fatal error U1077: return code '0xc0000135' :

    [...] "Which means that you did not start nmake in a Visual Studio command shell. If you want to use a standard command shell you have to call vcvarsall.bat or similar in the VC directory of you Visual Studio installation"

How I compiled the extension:

  • download Visual studio community 2022 and install ALL component related to windows and C++ (I say ALL to not being bother with missing lib but if you lack of space you could cherry pick the lib to install)

  • find where is the vcvarsall.bat file (usually: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build)

  • download the pgvector extension from github and place it in a easily callable folder like: c:/pgvector

  • find the root folder of your postgresql installation (like: C:\Program Files\PostgreSQL\15)

  • identify the CPU you are using because you will need to choose a parameter later:

    vcvarsall.bat x86_amd64
    vcvarsall.bat x86_amd64 10.0.10240.0
    vcvarsall.bat x86_arm uwp 10.0.10240.0
    vcvarsall.bat x86_arm onecore 10.0.10240.0 -vcvars_ver=14.0
    vcvarsall.bat x64 8.1
    vcvarsall.bat x64 store 8.1

  • you are now ready !

  • find in the windows bar the following tool: Developer Command Prompt for VS 2022

  • type the following commands (adapt it if needed):

    cd C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build
    vcvarsall.bat x64
    set "PGROOT=C:\Program Files\PostgreSQL\15"
    cd c:/pgvector
    nmake /F Makefile.win
    nmake /F Makefile.win install
    

It works for me on two computers, hope it will work for you as well or could help other users in the future.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Cesco2142
  • 61
  • 6
  • In Windows you have to execute cmd as administrator for "nmake /F Makefile.win install", like sudo. Works for me. – Xeppit Jun 03 '23 at 20:29