【问题标题】:Error with static compilation Qt with postgresql driver使用 postgresql 驱动程序静态编译 Qt 时出错
【发布时间】:2019-10-28 01:36:33
【问题描述】:

我已经通过维护工具 Qt 5.12.5 和源安装。我有下一个目录:

C:\Qt\5.12.5\Src 
C:\Qt\Tools\mingw730_32\
C:\Qt\Tools\mingw730_64\

另一方面,我读到可下载的 Postgres 版本是用 MSVC 编译的,我必须编译自己的版本。我已经按照link 做了,现在我在c:\pgsql 中有一个postgresql 版本

最后我将c:\pgsql添加到用户路径

下一步,我已在管理员模式下打开 PowerShell,我已转到 C:\Qt\5.12.5\Src\

接下来,为此 PowerShell 会话设置 env 路径: $env:Path += ";C:\Qt\Tools\mingw730_64\bin\;C:\Qt\5.12.5\Src;C:\pgsql\include\;C:\pgsql\lib\;C:\pgsql\bin\"(再次设置pgsql路径....)

之后,我就这样执行configure.bat

configure -v -static -release -static-runtime -platform win32-g++ -prefix C:\Qt\5.12.5\Estatico\ -opensource -confirm-license -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -no-openssl -opensource -confirm-license -skip webengine -make libs -nomake tools -nomake examples -nomake tests -sql-psql

但是我收到了这个错误:

ERROR: Feature 'sql-psql' was enabled, but the pre-condition 'libs.psql' failed.

config.log 中搜索我可以阅读这些行:

loaded result for library config.qtbase_sqldrivers.libraries.psql
Trying source 0 (type pkgConfig) of library psql ...
pkg-config use disabled globally.
  => source produced no result.
Trying source 1 (type psqlConfig) of library psql ...
pg_config not found.
  => source produced no result.
Trying source 2 (type psqlEnv) of library psql ...
None of [liblibpq.dll.a liblibpq.a libpq.dll.a libpq.a libpq.lib] found in [] and global paths.
  => source produced no result.
Trying source 3 (type psqlEnv) of library psql ...
  => source failed condition '!config.win32'.
test config.qtbase_sqldrivers.libraries.psql FAILED

我能做什么或正确的方法是什么? 提前谢谢你。

更新

有类似的问题here,但还没有解决,这些问题是关于 Visual Studio 的。

我想在mingw下编译。

@Soheil Armin 建议的解决方案也不起作用 @Soheil Armin 建议的解决方案工作正常,但我需要删除整个源代码树并按照他的建议重新安装它。如果没有,新的配置将不起作用。 另外,^ 字符可以保存:

configure <your parameters> 
PSQL_LIBS="C:\pgsql\lib\libpq.a" 
-I "C:\pgsql\include" 
-L "C:\pgsql\lib"

【问题讨论】:

标签: postgresql qt compiler-errors


【解决方案1】:

您需要明确定义 Postgres 的库路径。

configure <your parameters> ^
PSQL_LIBS="C:\pgsql\lib\libpq.a" ^
-I "C:\pgsql\include" ^
-L "C:\pgsql\lib"

【讨论】:

  • 谢谢,但它对我不起作用。但我可以看到我没有 libpq.lib,只有 libpq.a 和 libpq.dll。我会更新问题
  • 好的。只需像使用 mingw 一样使用 libpq.a 即可。重试前不要忘记清理配置: git submodule foreach --recursive "git clean -dfx"
  • 再次感谢您。它也不起作用。我还没有从 Git 下载源代码……我需要清理配置吗?如果是,我该怎么做?
  • 你可以 make/nmake distclean 但有时它不起作用。最好删除整个目录并从存档中重新提取。
  • 已解决。最糟糕的是,每次我出错时都必须重新安装源。我花了很长时间。如果没有,新的配置不起作用。 distclean 也不起作用。另外,选项字符串中不需要写“^”符号。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-13
  • 2021-11-07
  • 2011-01-20
  • 2013-08-07
  • 2017-11-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多