英文:
Resolving LNK4272 errors
问题
I have a problem with Pgvector extension installation on Windows.
所以安装的代码如下:
set "PGROOT=C:\Program Files\PostgreSQL"
git clone --branch v0.4.2 https://github.com/pgvector/pgvector.git
cd pgvector
nmake /F Makefile.win
nmake /F Makefile.win install
而我遇到了致命错误:
C:\Program Files\pgvector>nmake /F Makefile.win
C:\Program Files\PostgreSQL\15\lib\postgres.lib:警告 LNK4272:库的机器类型 'x64' 与目标机器类型 'x86' 冲突
vector.dll:致命错误 LNK1120:109 个未解析的外部符号
除此之外,我还遇到了一堆 LNK 2001 和 2019 错误。
我正在使用:
MSVC v143 软件包
Windows 通用 CRT SDK
Windows 10 SDK
英文:
i have a problem with Pgvector extension installation on Windows
so the code for installation is
set "PGROOT=C:\Program Files\PostgreSQL"
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
答案1
得分: 2
我不是编译专家,但我设法完成了。以下是我是如何做的:
- 首先,你不能直接从命令提示符工具中运行 nmake:https://stackoverflow.com/questions/6622869/nmake-fatal-error-u1077-return-code-0xc0000135:
> [...] "这意味着你没有在 Visual Studio 命令行中启动 nmake。如果你想要使用标准命令行,你必须在你的 Visual Studio 安装目录的 VC 目录中调用 vcvarsall.bat 或类似的文件。"
我是如何编译这个扩展的:
-
下载并安装 Visual Studio Community 2022,包括与 Windows 和 C++ 相关的所有组件(我说“所有”是为了避免因缺少库而麻烦,但如果空间不足,你也可以选择性安装库)。
-
找到 vcvarsall.bat 文件的位置(通常位于:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build)。
-
从 GitHub 下载 pgvector 扩展并将其放在一个容易调用的文件夹中,比如:c:/pgvector。
-
找到你的 PostgreSQL 安装的根文件夹(例如:C:\Program Files\PostgreSQL\15)。
-
识别你正在使用的 CPU,因为稍后你将需要选择一个参数:
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 -
你现在已经准备好了!
-
在 Windows 工具栏中找到以下工具:Developer Command Prompt for VS 2022。
-
输入以下命令(如果需要,请进行适当的调整):
cd C:\Program Files\Microsoft Visual Studio22\Community\VC\Auxiliary\Build vcvarsall.bat x64 set "PGROOT=C:\Program Files\PostgreSQL" cd c:/pgvector nmake /F Makefile.win nmake /F Makefile.win install
这对我在两台计算机上都有效,希望对你也有用,或者可以帮助将来的其他用户。
英文:
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: https://stackoverflow.com/questions/6622869/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 Studio22\Community\VC\Auxiliary\Build vcvarsall.bat x64 set "PGROOT=C:\Program Files\PostgreSQL" 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论