Xathrya Sabertooth |
Creating MySQL Driver for Qt5 on Windows Posted: 03 Oct 2013 09:43 PM PDT This article will discuss on how to create MySQL driver for Qt4 on Windows using MinGW. This article is motivated by the fact that MySQL driver isn’t shipped by default on Qt5. All the works are done using:
Actually my Windows 8 is 64-bit, but all program we test here is 32-bit version (MinGW32, MySQL 32-bit). Obtain MaterialsFor this article we need Qt libraries, Qt source code, and MySQL server. Qt version I use is 5.1.1. You need to download two separate files (libraries and source code). We also need MySQL server and the library. The version I use is 5.6.14 which you can download here. The reason why I didn’t use the 64-bit version simply because my current project should produce 32-bit app. If you want to follow this article, make sure all the materials are 32-bit. Installation the MaterialsInstalling QtInstall Qt libraries. Installing default components would do alright. Although you can use full installation, but in this article we will use the default one. I select drive C:\ like default path and leave it to Qt. At the end, the Qt is installed as C:\Qt\Qt5.1.1 Next, extract the Qt sources to a folder you choose. Let’s extract it to the same folder as Qt libraries does. Which means, the target path is C:\Qt\Qt5.1.1. Rename the long name “qt-everywhere-opensource-src-5.1.1″ to “sources”. Thus, we have C:\Qt\Qt5.1.1\sources. Installing MySQLInstall MySQL. Select custom installation. At minimal, you need to install Client C API Library, the other components are optional. Let’s installed it under C:\Program Files (x86)\MySQL\MySQL Server 5.6 Building & DeployingOpen Qt command prompt, You should have one. It is like normal command prompt, except it has default Qt environment variable we need. Once you open it, you will be brought to your Qt directory. Now execute following: set mysql=C:\\PROGRA~2\\MySQL\\MYSQLS~1.6 cd C:\Qt\Qt5.1.1\sources\qtbase\src\plugins\sqldrivers\mysql\ qmake "INCLUDEPATH+=%mysql%\\include" "LIBS+=%mysql%\\lib\\libmysql.lib" -o Makefile mysql.pro mingw32-make Once it is built successfully without error, you will have some fileson C:\Qt\Qt5.1.1\sources\qtbase\plugins\sqldrivers. They are:
For .dll files, move them to C:\Qt\QT5.1.1\5.1.1\mingw48_32\plugins\sqldrivers. For .a files, move them to C:\Qt\Qt5.1.1\5.1.1\mingw48_32\lib Also, copy libmysql.dll from %mysql%\lib to C:\Windows TestingTo use the driver, don’t forget to add QT += sql to project file, else it don’t work. Check which drivers are available by this code: #include <QtCore/QCoreApplication> #include <QtSql> int main() { QCoreApplication a(argc, argv); aDebug() << QSqlDatabase::drivers(); return a.exec(); } |
Deleting hiberfil.sys File and Reclaim the Hard Disk Space Posted: 03 Oct 2013 04:03 AM PDT Hibernate is one of feature of Microsoft Windows operating system. When hibernating, Windows creates a hiberfil.sys file. This file might become large in size and consume much your partition. This file is created by default if you have ever used Hibernate feature in Microsoft Windows. The hibernate file is stored on system root directory. In this article we will discuss about how we can safely delete hiberfil.sys file and reclaim the hard disk space. When You Do and Don’tIf you use hibernate all the time, or frequently use it, then you are not supposed to delete it. This is the mechanism of Windows. But if you do not use Hibernate, you may proceed. Understanding the Windows Hibernate FunctionWhen you activate hibernate, Windows take a snapshot of current session (all running programs, open files, etc). These information then written to hard drives (like dumping the state). When you go back powering your machine, Windows then read the hiberfil.sys and restore all of these informations. This way, Windows can speed up shutdowns and starting process. The file size is mostly equivalent to your RAM size and other parameter. Hiberfile.sys, having large file just hanging around is problematic for you if you have low disk space. Disabling Windows HibernationYou can manually delete hiberfil.sys, but it will just come back. To permanently remove the file, you must disable the Windows Hibernate function. The easiest and portable way is do it on your command prompt. Open your command prompt (cmd.exe) and write this command: powercfg.exe -h off On some latest Windows version, you need to run it as Administrator. As soon as you execute the powercfg command, Windows should delete hiberfil.sys. If not, you can manually delete it. Re-Enabling Windows HibernationTo make Windows re-enable hibernation feature, it is simply reciprocal procedure to disable one. Open up command prompt and execute following command with Administrator rights: powercfg.exe -h on |
You are subscribed to email updates from Xathrya Sabertooth To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Tidak ada komentar:
Posting Komentar