Last active
August 29, 2015 13:57
-
-
Save guange2015/9500169 to your computer and use it in GitHub Desktop.
Qt5 静态编译如何加载plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 只讨论qt5, 这里以qt5.2.0 + sqlite3来举例 | |
| 1. 静态编译时记得把plugin编译进去, 下面的编译选项,可以在configure时查看 | |
| ` -qt-sql-sqlite -plugin-sql-sqlite ` | |
| 2. 编译之后察看一下是否编译成功,值得注意的是qt把sqlite3的源码已经带进去了,所以不需要去下sqlite3的源码。 | |
| 在源码+qtbase/plugins/sqldrivers/ 目录下应该存在.a之类的lib类,我这里是libqsqlite.a | |
| 3. 修改你的.pro工程文件 | |
| QTPLUGIN += qsqlite #这里写好你的plugin名,作用相当于 LIBS += sqlitelib的路径 | |
| 4. 在main.cpp中引入你的plugin | |
| ```c++ | |
| #include <QtPlugin> | |
| Q_IMPORT_PLUGIN (QSQLiteDriverPlugin); | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment