开发者

Qt sqlite deploy exe

开发者 https://www.devze.com 2022-12-09 19:35 出处:网络
I have a Qt .exe built from Visual Studio 2005 (after taking the .cpp, .h, .moc, ui_ files) I have done some simple QSqlite queries. It works fine in my development pc. But in another pc it crashes f

I have a Qt .exe built from Visual Studio 2005 (after taking the .cpp, .h, .moc, ui_ files)

I have done some simple QSqlite queries. It works fine in my development pc. But in another pc it crashes for the line below:

QSqlDatabase mSqlDb

How can I run the .exe so that it can interact with sqlite on another PC? [Other GUI application run just fine.]

What th开发者_StackOverflowings are necessary to deploy a sqlite-qt application?


I'd give you a better answer, but you tend to not accept answers, so here is a link to the documentation: Deploying an Application on Windows - Qt Plugins :)


If you have Qt with shared libraries (standard compiled Qt download is Qt with shared libraries), you must follow this 2 easy steps:

1) tell QtCore to seach for plugins in 'your_directory' (use 'qApp->addLibraryPath(".")' to point into same directory, where your binary shall stay)

2) create subdirectory 'sqldrivers' in 'your_directory' and copy 'qsqlite4.dll' plugin in it (qsqlite4.dll plugin is in $$QT_DIR/plugins/sqldrivers/ directory)


I've just successfully compiled a static version (you have to compile it statically to avoid dependency problems) of a program that uses qt sqlite library with a MinGw compiler (bundled with Qt). Here are the steps that I used:

  1. Open command line and run c:\\bin\qtenv.bat
  2. The go to c:\\qt\
  3. and run this: "configure -static -release -nomake demo -nomake examples -no-exceptions -qt-sql-sqlite"
  4. Then run this: "mingw32-make src-sub"
  5. If you get some "phonon" error during compilation, then run "mingw32-make confclean" and then add "-no-phonon" parameter to command on 3. step and continue from there
  6. Wait for few hours
  7. Go to your project folder
  8. Run "qmake"
  9. Run "mingw32-make"
  10. Check the release folder, it should work

Good luck...

0

精彩评论

暂无评论...
验证码 换一张
取 消