0

I use QtCreator + mingw.

I have compiled QSQLITE2 plugin. I simply entered plugin directory in Qt source code:

c:\Qt\Qt5.2.0\5.2.0\Src\qtbase\src\plugins\sqldrivers\sqlite

and I built it with my sqlite 2.8.17 that I have locally (as dll and header):

qmake "LIBS+=-Lc:\projects\lib -lsqlite" "INCLUDEPATH+=c:\projects\include"
make
make install

Everything builds okay.

Now, I have another DLL (also implemented as Qt plugin, a custom one), which makes use of QSQLITE2 Qt plugin. My own dll is also linked to sqlite.dll. So it looks like this:

my.dll                       depends on sqlite.dll
%QT_PLUGINS%\qsqlite2d.dll   depends on sqlite.dll
my.dll                       uses qsqlite2d.dll through Qt's plugin engine
myApp.exe                    loads my.dll

Problem is that my application cannot load my.dll, because of invalid location access or something like that. I don't know any details and that's the problem.

The sqlite.dll is in the application directory when running it.

When I run application in debug mode, it crashes in some assembly file, but in stack trace I can see that it's somewhere inside sqlite.dll, in sqlite_step symbol. That's all I know.

Note 1) I have another plugin dll, the my3.dll, which uses QSQLITE plugin (it's for sqlite3) and is linked with sqlite3.dll and this one loads just fine. I have compiled QSQLITE plugin myself as well (even there was the one provided with Qt, that's because Qt linked statically to sqlite3 and I wanted it to link dynamically to sqlite3.dll).

Note 2) Both plugins work just fine under Linux.

Any hints what might be wrong? What else can I check?

EDIT:

I've just performed a test: I deleted my.dll from plugins to avoid loading it at all. Then I added code to main.cpp:

    QSqlDatabase::addDatabase("QSQLITE2", ":memory:");

Thing is, that it also crashed, with the very same stack trace (at this very line, I debugged it). Thus I think there's something wrong with sqlite2 Qt plugin, but I'm still unable to tell what. I looked up for other sqlite.dll, I just downloaded the one from sqlite.org: http://www.sqlite.org/sqlitedll-2_8_17.zip - so it's official build, but it's the exactly the same file I had and it also fails the same way.

Maxim Makhun
  • 2,197
  • 1
  • 22
  • 26
Googie
  • 5,742
  • 2
  • 19
  • 31
  • One more note: sqlite.h defines `extern const char sqlite_encoding[]` which is not defined in the sqlite.dll (I could not compile QSQLITE2 plugin), so I have to edit file `qsql_sqlite2.cpp` and add line: `const char sqlite_encoding[] = "UTF-8";` - then Qt plugin compiled correctly. I'm not sure if that's relevant, but just wanted to be precise. – Googie Feb 04 '14 at 14:05

1 Answers1

0

It turned out that qsqlite2d.dll cannot be linked sqlite.dll, because sqlite.dll is not compiled in debug mode. After recompiling application in release mode (thus using qsqlite2.dll, not qsqlite2d.dll), the plugin loads correctly and works.

This makes sense, but just one more thing that bugs me - qsqlited.dll (for sqlite3) had no problem linking with sqlite3.dll. No matter if I compiled debug or release - the single sqlite3.dll worked with both debug and release plugins. Anyone has an idea how is that possible? Please comment if you do, I'd appreciate it.

Googie
  • 5,742
  • 2
  • 19
  • 31