使用postgresql驱动程序进行静态编译时出错

使用postgresql驱动程序进行静态编译时出错,postgresql,qt,compiler-errors,Postgresql,Qt,Compiler Errors,我已通过维护工具Qt 5.12.5和源安装。我有以下目录: C:\Qt\5.12.5\Src C:\Qt\Tools\mingw730_32\ C:\Qt\Tools\mingw730_64\ 另一方面,我读到downloable Postgres版本是用MSVC编译的,我必须编译我自己的版本。我已经完成了以下工作,现在我在c:\pgsql 最后,我在用户路径中添加了c:\pgsql 下一步,我在管理模式下打开了PowerShell,并转到C:\Qt\5.12.5\Src\ 接下来,设置此P

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

C:\Qt\5.12.5\Src 
C:\Qt\Tools\mingw730_32\
C:\Qt\Tools\mingw730_64\
另一方面,我读到downloable Postgres版本是用MSVC编译的,我必须编译我自己的版本。我已经完成了以下工作,现在我在
c:\pgsql

最后,我在用户路径中添加了
c:\pgsql

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

接下来,设置此PowerShell会话的环境路径:
$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
我能做什么,或者正确的方法是什么? 先谢谢你

更新

也有类似的问题,但还没有解决,这些问题都是关于VisualStudio的

我想在mingw下编译它

@Soheil Armin提出的解决方案也不起作用 @Soheil-Armin建议的解决方案运行良好,但我需要删除整个源代码树,并按照他的建议重新安装。否则,新配置将不起作用。 此外,还可以保存
^
字符:

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

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

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

Thank you的可能副本,但对我不起作用。但是我可以看到我没有libpq.lib,只有libpq.a和libpq.dll。我将更新问题OK。只需像使用mingw一样使用libpq.a。在重试之前不要忘记清理配置:git子模块foreach——递归的“git clean-dfx”再次感谢您。它也不起作用。我还没有从Git加载源代码…我需要任何配置清理吗?如果是,我该怎么做?您可以使/n使distclean清洁,但有时它不起作用。最好删除整个目录,然后再次从archive.Solved中提取它。最糟糕的是,每次我出错时都必须重新安装源代码。我花了很长时间。如果没有,新的配置就不起作用。蒸馏器也不起作用。此外,不必在选项字符串中写入“^”符号。非常感谢。