gpt4 book ai didi

c++ - 如何解决使用静态 QT odbc 时的链接问题

转载 作者:行者123 更新时间:2023-11-30 03:49:57 25 4
gpt4 key购买 nike

我目前正在使用配置了命令行的 Qt 4.7.4

-static -debug-and-release -opensource -platform win32-msvc2010 -qt-sql-odbc -qt-sql-sqlite

在没有添加 SQL 库的情况下尝试重新运行最初工作的程序后,我收到大约 30 个链接错误。

1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLGetInfoW@20 referenced in function "public: class QChar __thiscall QODBCDriverPrivate::quoteChar(void)" (?quoteChar@QODBCDriverPrivate@@QAE?AVQChar@@XZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLSetConnectAttrW@16 referenced in function "public: bool __thiscall QODBCDriverPrivate::setConnectionOptions(class QString const &)" (?setConnectionOptions@QODBCDriverPrivate@@QAE_NABVQString@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLGetDiagRecW@32 referenced in function "class QString __cdecl qWarnODBCHandle(int,void *,int *)" (?qWarnODBCHandle@@YA?AVQString@@HPAXPAH@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLFreeHandle@8 referenced in function "public: virtual __thiscall QODBCResult::~QODBCResult(void)" (??1QODBCResult@@UAE@XZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLNumResultCols@8 referenced in function "protected: virtual bool __thiscall QODBCResult::reset(class QString const &)" (?reset@QODBCResult@@MAE_NABVQString@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLGetStmtAttrW@20 referenced in function "protected: virtual bool __thiscall QODBCResult::reset(class QString const &)" (?reset@QODBCResult@@MAE_NABVQString@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLExecDirectW@12 referenced in function "protected: virtual bool __thiscall QODBCResult::reset(class QString const &)" (?reset@QODBCResult@@MAE_NABVQString@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLSetStmtAttrW@16 referenced in function "protected: virtual bool __thiscall QODBCResult::reset(class QString const &)" (?reset@QODBCResult@@MAE_NABVQString@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLAllocHandle@12 referenced in function "protected: virtual bool __thiscall QODBCResult::reset(class QString const &)" (?reset@QODBCResult@@MAE_NABVQString@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLColAttributeW@28 referenced in function "class QSqlField __cdecl qMakeFieldInfo(class QODBCPrivate const *,int)" (?qMakeFieldInfo@@YA?AVQSqlField@@PBVQODBCPrivate@@H@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLDescribeColW@36 referenced in function "class QSqlField __cdecl qMakeFieldInfo(class QODBCPrivate const *,int)" (?qMakeFieldInfo@@YA?AVQSqlField@@PBVQODBCPrivate@@H@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLFetchScroll@12 referenced in function "protected: virtual bool __thiscall QODBCResult::fetch(int)" (?fetch@QODBCResult@@MAE_NH@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLFetch@4 referenced in function "protected: virtual bool __thiscall QODBCResult::fetchNext(void)" (?fetchNext@QODBCResult@@MAE_NXZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLGetData@24 referenced in function "protected: virtual class QVariant __thiscall QODBCResult::data(int)" (?data@QODBCResult@@MAE?AVQVariant@@H@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLRowCount@8 referenced in function "protected: virtual int __thiscall QODBCResult::numRowsAffected(void)" (?numRowsAffected@QODBCResult@@MAEHXZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLPrepareW@12 referenced in function "public: virtual bool __thiscall QODBCResult::prepare(class QString const &)" (?prepare@QODBCResult@@UAE_NABVQString@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLExecute@4 referenced in function "public: virtual bool __thiscall QODBCResult::exec(void)" (?exec@QODBCResult@@UAE_NXZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLBindParameter@40 referenced in function "public: virtual bool __thiscall QODBCResult::exec(void)" (?exec@QODBCResult@@UAE_NXZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLCloseCursor@4 referenced in function "public: virtual bool __thiscall QODBCResult::exec(void)" (?exec@QODBCResult@@UAE_NXZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLMoreResults@4 referenced in function "protected: bool __thiscall QODBCResult::nextResult(void)" (?nextResult@QODBCResult@@IAE_NXZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLDriverConnectW@32 referenced in function "public: virtual bool __thiscall QODBCDriver::open(class QString const &,class QString const &,class QString const &,class QString const &,int,class QString const &)" (?open@QODBCDriver@@UAE_NABVQString@@000H0@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLSetEnvAttr@16 referenced in function "public: virtual bool __thiscall QODBCDriver::open(class QString const &,class QString const &,class QString const &,class QString const &,int,class QString const &)" (?open@QODBCDriver@@UAE_NABVQString@@000H0@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLDisconnect@4 referenced in function "private: void __thiscall QODBCDriver::cleanup(void)" (?cleanup@QODBCDriver@@AAEXXZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLGetFunctions@12 referenced in function "public: bool __thiscall QODBCDriverPrivate::checkDriver(void)const " (?checkDriver@QODBCDriverPrivate@@QBE_NXZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLEndTran@12 referenced in function "protected: virtual bool __thiscall QODBCDriver::commitTransaction(void)" (?commitTransaction@QODBCDriver@@MAE_NXZ)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLTablesW@36 referenced in function "public: virtual class QStringList __thiscall QODBCDriver::tables(enum QSql::TableType)const " (?tables@QODBCDriver@@UBE?AVQStringList@@W4TableType@QSql@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLSpecialColumnsW@40 referenced in function "public: virtual class QSqlIndex __thiscall QODBCDriver::primaryIndex(class QString const &)const " (?primaryIndex@QODBCDriver@@UBE?AVQSqlIndex@@ABVQString@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLPrimaryKeysW@28 referenced in function "public: virtual class QSqlIndex __thiscall QODBCDriver::primaryIndex(class QString const &)const " (?primaryIndex@QODBCDriver@@UBE?AVQSqlIndex@@ABVQString@@@Z)
1>QtSqld.lib(qsql_odbc.obj) : error LNK2019: unresolved external symbol _SQLColumnsW@36 referenced in function "public: virtual class QSqlRecord __thiscall QODBCDriver::record(class QString const &)const " (?record@QODBCDriver@@UBE?AVQSqlRecord@@ABVQString@@@Z)

我假设我没有在我的链接参数中包含库,或者我没有正确配置 QT。

谁有这方面的经验?请注意,我知道在处理 SQL 插件时将 QT 编译为非静态形式要容易得多,但目前 QT 库必须以静态形式编译。

最佳答案

您的 Qt 安装可能没问题。当您使用 ODBC 时,应用程序 must be linked不过,使用 odbc32.lib。为此,将以下内容添加到您的 .pro 文件中:

LIBS += -lodbc32

使用动态库时不必这样做的原因是 SQL ODBC 插件 .dll 已经链接到 odbc32。由于携带此类信息的是可执行格式(.dll/.exe),而不是静态插件.lib,因此您必须自己处理。

为了完全正确,有一种方法可以在目标文件中嵌入链接器指令,然后将其捆绑在 .lib 中,但 Qt 没有使用这种方法,因为它使它变得更加困难推断传递给链接器的完整参数集 - 有些来自命令行,有些来自输入对象。

关于c++ - 如何解决使用静态 QT odbc 时的链接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32140268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com