PostgreSQL libpq windows 10 CMake丢失的PostgreSQL库

q5lcpyga  于 2022-11-11  发布在  PostgreSQL
关注(0)|答案(4)|浏览(380)

我想在Windows 10下使用PostgreSQL设置一个CMake项目。
当我尝试find_package

find_package(PostgreSQL REQUIRED)

我得到以下错误

Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY) (found version
  "10.4")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.8/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.8/Modules/FindPostgreSQL.cmake:175 (find_package_handle_standard_args)
  server/CMakeLists.txt:13 (find_package)

它似乎找到了“10.4”版本,但缺少PostgreSQL_LIBRARY
我该怎么解决这个问题?

yqyhoc1h

yqyhoc1h1#

我有同样的目标--尝试在CMake项目中使用Windows 10上的PostgreSQL libpq,但我遇到了同样的错误。根据Mike的回复,我在调用find_package(PostgreSQL REQUIRED)之前添加了set(PostgreSQL_ADDITIONAL_VERSIONS "14"),并可以确认这修复了问题。只是确认Mike的解决方案对我有效。

oknrviil

oknrviil2#

我的FindPostgreSQL.cmake有这样的注解:


# Note:

# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the

# version number of the implementation of PostgreSQL.

# In Windows the default installation of PostgreSQL uses that as part of the path.

# E.g C:\Program Files\PostgreSQL\8.4.

# Currently, the following version numbers are known to this module:

# "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"

# 

# To use this variable just do something like this:

# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")

# before calling find_package(PostgreSQL) in your CMakeLists.txt file.

# This will mean that the versions you set here will be found first in the order

# specified before the default ones are searched.

# 

# ----------------------------------------------------------------------------

# You may need to manually set:

# PostgreSQL_INCLUDE_DIR  - the path to where the PostgreSQL include files are.

# PostgreSQL_LIBRARY_DIR  - The path to where the PostgreSQL library files are.

# If FindPostgreSQL.cmake cannot find the include files or the library files.

高温
麦克

km0tfn4u

km0tfn4u3#

将PostgreSQL lib、bin、include目录添加到环境变量中

kxxlusnw

kxxlusnw4#

如果您使用自制软件安装/更新了PostgreSQL,这可能会有所帮助。
CMake最近更新了PostgreSQL和自制软件。引用自CMake commit:自14.5起,homebrew使用版本号命名PostgreSQL目录,例如postgresql@14
将CMake更新到最新版本为我修复了这个问题。Installing cmake with homebrew**注意:**我的答案与PostgreSQL 14.5之后遇到相同或类似问题的人相关。

相关问题