Search code examples
dllsqlited

How to use SQLite library in D language program on Windows?


How to use SQLite3 library in D language program on Windows?

I found a similar question with Ubuntu, but it didn't work in my case.

import std.stdio, std.string, etc.c.sqlite3;

void main () {
  sqlite3* db;
  auto ret = sqlite3_open (toStringz("mydb.s3db"), &db);
  writeln (ret);
}

As I assume, the sqlite3.d is some kind of header to the real SQLite3 library. I've got an sqlite3.dll, but I have no idea about how to link it with my program. pragma works only with lib formate (like pragma(lib, "sqlite3")).

Maybe I should use the SQLite sources, but how is it possible to compile it together with D code? Or is it better to find some way to convert dll to lib?

What is a general method to solve such problems in D?


Solution

  • Or is it better to find some way to convert dll to lib?

    Yes. From the question Statically linking SQLite with DMD (Windows x86), just run the .dll file through implib with the /system switch (linking with the resulting .lib file will still result in dynamic linkage and a dependency on the .dll file).