10

I am wondering if we able to embed SQlite library into Delphi executable file and we may deploy our application as single .exe file without any SQlite dll file.

The embed is not keep the sqlite dll file into resource but link to Delphi executable file.

Chau Chee Yang
  • 18,422
  • 16
  • 68
  • 132

6 Answers6

6

I have not tried this component out, but I plan to in the future Delphi Inspiration - DISQLite3

There is also Synopse OpenSource SQLite3 Framework

A Freeware version is available too

Sigurdur
  • 417
  • 4
  • 10
  • 1
    Our [SQLite3 dedicated classes](http://blog.synopse.info/post/2011/07/22/SynDBSQLite3%3A-SQLite3-direct-access) can now be easily used outside the scope of our ORM framework. They can also be replaced by another database engine, if needed (via OleDB or direct Oracle access). – Arnaud Bouchez Nov 11 '11 at 06:31
5

We have compiled SQLite3 with Borland's free command line tools C compiler and the resulting OBJ file we linked in Delphi with {$LINK 'OBJS\sqlite3.obj'}, and written the pascal wrappers for the functions we needed.

There was a problem resolving some standard C library functions when linking but we re-implemented them in Delphi.

r4w8173
  • 598
  • 6
  • 15
  • 2
    This is exactly what we did with our [Open Source binding of SQLite3](http://blog.synopse.info/post/2011/07/22/SynDBSQLite3%3A-SQLite3-direct-access). So you have all [the source code at hand](http://synopse.info/fossil/artifact?name=37195887f6c0e17ca8217704223a440817e087ee) - especially the standard C library equivalencies in pure Delphi code (this is not so obvious). – Arnaud Bouchez Nov 11 '11 at 06:35
4

Anydac SQLite driver has statically linked SQLite engine. It is commercial library, although. They has an article about anydac and sqlite.

robmil
  • 312
  • 2
  • 4
4

I had the same problem and this is the solution I came up with. Maybe it can help you. Just include sqlite3 and you then have direct access to the dll functions. I used the same methods that have already be outlined: http://simvector.com/download/delphi_sqlite3.zip

The DLL is just encoded in source form and the DLLLoader unit loads it at runtime. The end result is no extra DLL in your distro at the expense of it all being loaded into memory at once vs parts loaded on demand via the OS.

We needed it to work as normal, yet no extra dll in distro. So works for our needs.

  • This seems to be an interesting solution. I think it is a favor solution over DISqlite – Chau Chee Yang May 21 '11 at 01:35
  • Yea I've been using this method in my code base for some time now and it has worked out well. – Simvector Technologies May 21 '11 at 12:57
  • I think keep the sqlite dll into resource and load into the the dll loader should be the way to go. I never know we may load the dll from memory stream. Thanks for showing me the example. – Chau Chee Yang May 22 '11 at 01:33
  • I just found this site: http://synopse.info/fossil/wiki?name=SQLite3+Framework from what I can tell, I think it's been translated to Delphi. If so then we no longer have to go through these extra hoops. – Simvector Technologies May 24 '11 at 01:26
  • The original zip file is no longer online. There is a guide on how to load a DLL from a resource into a TMemoryStream and then use it directly without writing it to disk: http://delphi.about.com/od/windowsshellapi/a/delphi-load-resource-dll-into-memory.htm – Mick Oct 31 '11 at 02:21
  • I don't like this approach at all. Much better to link the code statically. Unpacking DLLs is clunky and makes your program look like malware. – David Heffernan Feb 14 '14 at 05:41
1

Delphi can link .obj files, thereby if you have them available (or source code to compile them), you can link them into an executable. But you can't to that with the SQLLite dll.

IIRC DISQLite 3 does exactly that, check it.

  • 1
    Very easy to say, but often very hard to do. You typically need to supply the C runtime functions too and for a large library that can be a devil of a job. Plus you have to deal with strange ordering issues when linking the .obj files: http://stackoverflow.com/questions/4638186/error-while-linking-multiple-c-object-files-in-delphi-2007 – David Heffernan May 20 '11 at 11:44
0

You can download the SQLite open source and compile it into any environment that can compile vanilla C code. It's not especially hard.

Hot Licks
  • 47,103
  • 17
  • 93
  • 151