日志
插件在静态编译release与动态编译debug共存工程中的配置(备忘)
2012-12-24 23:02
Qt静态编译时,使用插件要用Q_IMPORT_PLUGIN宏导入,比如odbc插件,简体中文支持插件
#include <QtPlugin> Q_IMPORT_PLUGIN(qsqlodbc) Q_IMPORT_PLUGIN(qcncodecs) 在pro文件中要加 QTPLUGIN += qsqlodbc QTPLUGIN += qcncodecs 而动态编译,就不能有这些。对于动静态共存的工程应该如何处理呢?可以用下面的方法, 在main.cpp文件中 #ifdef QT_NO_DEBUG #include <QtPlugin> Q_IMPORT_PLUGIN(qsqlodbc) Q_IMPORT_PLUGIN(qcncodecs) #endif 在pro文件中 CONFIG(release, debug|release) { QTPLUGIN += qsqlodbc QTPLUGIN += qcncodecs } CONFIG(debug, debug|release) { } 注意,左花括号一定要与CONFIG(xxxx, debug|release) 在同一行,否则起不到限定作用。 这样,工程在静态编译release版和动态编译debug版,都能正常进行了。 |