【问题标题】:PostgreSQL libpq windows 10 CMake missing PostgreSQL_LIBRARYPostgreSQL libpq windows 10 CMake 缺少 PostgreSQL_LIBRARY
【发布时间】:2018-08-04 20:59:21
【问题描述】:

我正在尝试使用 PostgreSQL 在 Windows 10 下设置一个 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

我该如何解决这个问题?

【问题讨论】:

  • 我记得我在 FreeBSD 上使用 libpq 时遇到了一些问题。库存 pkg-libpq 正在使用 Postgres 版本。 9,我在哪里运行 10。这之间会不会不匹配?你在运行什么操作系统?窗户?
  • 是的,它是 Windows 10

标签: c++ windows postgresql cmake libpq


【解决方案1】:

我的 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.

HTH

迈克

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    • 2023-01-14
    • 2016-03-05
    • 1970-01-01
    相关资源
    最近更新 更多