Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QT QPSQL compile driver MSVC 2019 64
I want to compile the Postgresql driver for Qt5.15.2 MSVC 2019 64, as a result, I don't want to compile, although everything compiles perfectly under MinGW 8.1.0 64. Before reinstalling Windows, everything worked and compiled.
here is a screenshot of the compilation
QPsql Driver Compilation
the difference in .qmake.stash
an error also falls in the nmake log:
looking for library 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 ... + cd /d C:\Qt\5.15.2\Src\qtbase\src\plugins\sqldrivers\config.tests\psql && C:\Qt\5.15.2\msvc2019_64\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.7.25-winx64\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.7.25-winx64\\include C:\\Utils\\postgresql\\pgsql\\include" "QMAKE_USE += psql" "QMAKE_LIBS_PSQL = -LC:\\psql\\lib -llibpq -lws2_32 -ladvapi32" "QMAKE_INCDIR_PSQL = C:\\psql\\include" C:/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/config.tests/psql + cd /d C:\Qt\5.15.2\Src\qtbase\src\plugins\sqldrivers\config.tests\psql && set MAKEFLAGS=& nmake clean && set MAKEFLAGS=& nmake > Microsoft (R) Program Maintenance Utility Version 14.29.30136.0 > Copyright (C) Microsoft Corporation. All rights reserved. > del main.obj > ЌҐ г¤ Ґвбп ©вЁ C:\Qt\5.15.2\Src\qtbase\src\plugins\sqldrivers\config.tests\psql\main.obj > Microsoft (R) Program Maintenance Utility Version 14.29.30136.0 > Copyright (C) Microsoft Corporation. All rights reserved. > cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W0 -EHsc -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DNDEBUG -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.7.25-winx64\include -IC:\Utils\postgresql\pgsql\include -IC:\psql\include -IC:\Qt\5.15.2\msvc2019_64\mkspecs\win32-msvc -Fo @C:\Users\tomes\AppData\Local\Temp\nmA14B.tmp > main.cpp > C:\psql\include\libpq-fe.h(23): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.EXE"' : return code '0x2' > Stop. => source failed verification. Trying source 3 (type psqlEnv) of library psql ... => source failed condition '!config.win32'. test config.sqldrivers.libraries.psql FAILED looking for library sqlite2
how to overcome this attack ? I don't understand much in the settings. I understand that it is necessary to make the configuration. only how? and where?
why is it compiled under mingw, but does not want to under MSVC.
Cannot open include file: 'stdio.h': No such file or directory
Fix you MSVC installation, make sure you used the correct MSVC command line.
Thanks for the answer
Do you mean that you need to reinstall MSVC? I have a question why, when compiling with MSVC, there are no paths in the qmake.stash file, as it is for Mingw.
No reinstallation of MSVC needed, just have to make sure your current console is able to compile a simple main.cpp which includes stdio.h.
everything is compiled in visual studio, everything is compiled in visual studio. I think that it is necessary to indicate somewhere the paths to C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\SDK\scopecppsdk\vc15\SDK\include\ucrt stdio.h is located here
And that's done when you open a MSVC developer command prompt... so make sure you properly open it and a simple main.cpp as explained above can be compiled from there.
everything is compiled from the command line
So when there is an include of stdio.h then you should also be able to compile the qt sql driver there.
Thanks for the help compiled into the Command Line of native x64 tools for VS 2019. another question is how to add a driver to the project? and where is it located?
how to add a driver to the project?
Simply load it like any other Qt Sql driver: https://doc.qt.io/qt-5/qsqldatabase.html#details
and where is it located?
It must be under <QTDIR>/plugins/sqldrivers
in my project I use Qt 5.15.2 (MSVC 2019 64) but the same error fatal error C1034: stdio.h: no include path set is not compiled under it. How to configure?
How to configure?
As explained above - open the MSVC developer command prompt as @tomsmith did...
everything is solved everything works in the folder C:\Qt\5.15.2\msvc2019_64\bin I threw it libpq.dll and qsqlpsqld.dll
when compiling the driver from the Qt 5.15.2 window (MSVC2019 64), it was necessary to run C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat then compilation is performed without errors.
Thanks for the help.
t was necessary to run C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat then compilation is performed without errors.
This is what I told you ...
open the MSVC developer command prompt