Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sqlite

dll

d

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?

like image 266
Timushev Roman Avatar asked Dec 23 '13 22:12

Timushev Roman


2 Answers

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).

like image 60
Vladimir Panteleev Avatar answered Oct 16 '22 17:10

Vladimir Panteleev


You can also compile the sqlite source (with modification) using Digital Mars C copmiler which will then give you an object file you can statically link.

like image 3
he_the_great Avatar answered Oct 16 '22 16:10

he_the_great