如何在 Qt Creator 中添加 QtSql 库?

发布于 2024-09-11 02:00:09 字数 145 浏览 1 评论 0原文

当我编译具有数据库连接的代码时,出现错误,例如,

QtSql: No such file or directory

我认为sql库必须在Qt中,但我不知道为什么会发生错误? 如何启用数据库的库? 你能帮我吗,谢谢

when I compile the codes which has database connection, there's an error like,

QtSql: No such file or directory

I suppose that the sql library must be in Qt, but I dont have any idea why an error occured ?
what to do for enable the database's libraries?
Can you help me please, thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫卆 2024-09-18 02:00:09

来自 QtSql 文档,

在您的 .pro 您必须添加的文件,

QT += sql

据我所知,SQL 模块没有单独的库可供包含。如果您将以上行添加到您的 .pro 文件中就足够了。

由于您不知道添加库,

来自 qmake 可以使用LIBS关键字添加文档、库。

来自同一文档本身的示例..

unix:LIBS += -lmath -L/usr/local/lib
win32:LIBS += c:\mylibs\math.lib

From QtSql documentation,

In your .pro file you have to add,

QT += sql

AFAIK there is no separate library to be included for SQL module. It's enough if you add the above line to your .pro file.

Since you are not aware of adding libraries,

From qmake documentation, libraries can be added by using LIBS keyword.

An example from the same documentation itself..

unix:LIBS += -lmath -L/usr/local/lib
win32:LIBS += c:\mylibs\math.lib
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文