Recent

Author Topic: Embed SQLite C object files into application  (Read 3987 times)

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Embed SQLite C object files into application
« on: March 09, 2018, 02:11:50 pm »
Hi, according to this file
ftp://ftp.freepascal.org/fpc/docs-pdf/CinFreePascal.pdf

I can use, instead of a .DLL, the object files .o into FPC project.

This is the library I'm using
https://github.com/utelle/wxsqlite3

And instead of using the .dll, I want to incorporate that library into the executable.

My questions:

* There is a wrapping unit already made I can use to do that, I say the unit having all .o files listed, or I need to make it by myself?

* The .o files need to be compiled in each OS I want to deploy my application. Say .o files from Windows are not the same .o files from Mac / Linux?

* About the license of this fork of SQLite, doing that in a commercial application is right? maybe I need to ask in the project, but I also add this here if someone knows.

Thanks.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11459
  • FPC developer.
Re: Embed SQLite C object files into application
« Reply #1 on: March 09, 2018, 02:19:35 pm »
I can only answer the second one, no the .o's are not the same. They are different for each target. (so linux x86 and linux x86_64 differ too)

Moreover, you must also not just add the sqlite .o(bjs), but also any of requirements that these .o's have. Primarily the C runtime, but there might be more.

Static linking is a swamp.

Thaddy

  • Hero Member
  • *****
  • Posts: 14387
  • Sensorship about opinions does not belong here.
Re: Embed SQLite C object files into application
« Reply #2 on: March 09, 2018, 02:58:35 pm »
Marco is right about the second one.
I can answer the other two:
1. Yes, but you need to use a version of the headers that are not dynamically loaded.
3. The Sqlite license allows everything... But almost Nobody abuses it (I know of one single person). So a mention of its use is more than enough and proper.

Note that with static linking you can avoid dll hell, but you need to build Sqlite for every platform anyway. But that is really easy. It is not like a real swamp, more like muddy feet.
The mOrMoT project has good headers and good instructions. You may want to have a look at https://synopse.info/fossil/wiki/Synopse+OpenSource
« Last Edit: March 09, 2018, 03:10:19 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: Embed SQLite C object files into application
« Reply #3 on: March 09, 2018, 03:35:01 pm »
Thanks both.

@Thaddy I will try to find the headers in the site you provided.

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: Embed SQLite C object files into application
« Reply #4 on: March 10, 2018, 02:26:06 pm »
If someone is interested, here is the related thread on Synopse:
https://synopse.info/forum/viewtopic.php?pid=26777

Conclussion: Already possible! But they don't have the encryption support I use, so is not suitable for me this time. But for anyone else interested, mORMot is an already made solution with SQLite3 into the executable.

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: Embed SQLite C object files into application
« Reply #5 on: March 10, 2018, 04:16:03 pm »
If someone is interested, here is the related thread on Synopse:
https://synopse.info/forum/viewtopic.php?pid=26777

Conclussion: Already possible! But they don't have the encryption support I use, so is not suitable for me this time. But for anyone else interested, mORMot is an already made solution with SQLite3 into the executable.

I can confirm this. The way SQLite support is built into the framework is quite fascinating.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Thaddy

  • Hero Member
  • *****
  • Posts: 14387
  • Sensorship about opinions does not belong here.
Re: Embed SQLite C object files into application
« Reply #6 on: March 10, 2018, 04:58:42 pm »
If someone is interested, here is the related thread on Synopse:
https://synopse.info/forum/viewtopic.php?pid=26777

Conclussion: Already possible! But they don't have the encryption support I use, so is not suitable for me this time. But for anyone else interested, mORMot is an already made solution with SQLite3 into the executable.
If you have a pointer about which encryption support I can give you an example on how to recompile Sqlite-static so it still works with the mOrMot headers. AFAIK that should not be necessary since mOrMot supports encryption.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: Embed SQLite C object files into application
« Reply #7 on: March 10, 2018, 05:16:09 pm »
If you have a pointer about which encryption support I can give you an example on how to recompile Sqlite-static so it still works with the mOrMot headers. AFAIK that should not be necessary since mOrMot supports encryption.

Thanks, this is the library we're using
https://github.com/utelle/wxsqlite3

That has the encryption support.

The thing is of course I wish to use the mOrMot encryption, but the application has already a lot of customers using wxsqlite3 provided .dll with encryption, is not that simple to go and replace.

Code: Pascal  [Select][+][-]
  1. uses
  2. SQLite3Conn;
  3.  
  4. SQLite3Connection:=TSQLite3Connection.create(nil);
  5. SQLite3Connection.DatabaseName := dmConnection.gsDatabaseName;
  6. SQLite3Connection.Password:=  'password_here';

Another problem is that SQLite3Conn uses SQLite3Dyn, that forces using the .dll

That unit should be replaced / updated with the SynSQLite3Static.pas from mOrMot.

 

TinyPortal © 2005-2018