Nominate our 2022 Qt Champions!

[invalid] Build Postgres driver + LNK2019 / VS2010 / Win7

  • I try to build Postgres 9.2 driver using (Qt 5.0.2), but linker show errors. I specified libpq.lib in like this:
    @win32:LIBS += "C:\psql\lib\libpq.lib"
    LIBS += "C:\psql\lib\libpq.lib"@

    And called qmake / nmake, but linker prints:
    @qsql_psql.obj : error LNK2019: unresolved external symbol _PQfreemem referenced in function "void __cdecl qPQfreemem(void *)" (?qPQfreemem@@YAXPAX@Z)
    qsql_psql.obj : error LNK2019: unresolved external symbol _PQresultErrorField referenced in function "class QSqlError __cdecl qMakeError(class QString const &,enum QSqlError::ErrorType,class QPSQLDriverPrivate const *,struct pg_result *)" (?qMakeError@@YA?AVQSqlError@@ABVQString@@W4ErrorType@1@PBVQPSQLDriverPrivate@@PAUpg_result@@@Z)

    and so on.
    Makefile.Release / Makefile.Debug files in \sqldrivers\psql\ folder contain lines:
    @LINKER = link
    LIBS = libpq.lib ws2_32.lib advapi32.lib C:\psql\lib\libpq.lib /LIBPATH:C:\Qt\Qt5.0.2\5.0.2\msvc2010\lib C:\Qt\Qt5.0.2\5.0.2\msvc2010\lib\Qt5Sql.lib C:\Qt\Qt5.0.2\5.0.2\msvc2010\lib\Qt5Core.lib@

    And linker invocation from nmake output does not contain libpq.lib:
    @link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:........\plugins\sqldrivers\qsqlpsql.dll.embed.manifest /OUT:........\plugins\sqldrivers\qsqlpsql.dll @C:\Users\neurocod\AppData\Local\Temp\nmB549.tmp
    Creating library ........\plugins\sqldrivers\qsqlpsql.lib and object ........\plugins\sqldrivers\qsqlpsql.exp@

    I made "nmake clean" and rebuild, but got same error. Does linker receive lib files from nmake by environment variables? What other tools can be used to dig into this error? Maybe modify linker flags in Makefile* files to view additional information? As I understand, if linker couldn't find libpq.lib, it would print error like "file not found", so problem is other.

  • Solved: my Postgres is 64 bit and my Qt is 32

Log in to reply