Skip to content

Instantly share code, notes, and snippets.

@wincentbalin
Created December 22, 2017 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wincentbalin/27a83ff01da327ae22d06356b84ce585 to your computer and use it in GitHub Desktop.
Save wincentbalin/27a83ff01da327ae22d06356b84ce585 to your computer and use it in GitHub Desktop.
Get SQLite compile_options from Qt SQLite
#include <QCoreApplication>
#include <QTextStream>
#include <QSqlDatabase>
#include <QSqlQuery>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTextStream out(stdout);
QTextStream err(stderr);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(":memory:");
if (!db.open())
{
err << "Error opening database" << endl;
return 1;
}
QSqlQuery query;
if (!query.exec("PRAGMA compile_options"))
{
err << "Error querying compile options" << endl;
return 1;
}
out << "Qt built-in SQLite compile options:" << endl;
while (query.next())
out << query.value(0).toString() << endl;
return 0;
}
QT += core sql
QT -= gui
CONFIG += c++11
TARGET = sqlite_compile_options
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
@wincentbalin
Copy link
Author

Example for statically compiled Qt 4.8.7:
qt-4 8-sqlite-compile-options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment