Statically linking SQLite possible?

Windows specific forum
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Statically linking SQLite possible?

Post by dell_jockey »

Hi Group,

the last couple of weeks, I've been testing SQLite. I indent to make it part of an application of mine.

I've noticed that Kapital (http://www.kapital-billing.com/), a very nice billing application written by forum member Karbon uses SQLite, but apparently doesn't contain the sqlite.dll in the distribution. This leads me to the assuption, that SQLite can somehow be statically linked.

I searched this forum and read the SQLite docuementation, but couldn't find out how to statically link in SQLite.

I'd very much like to learn about how to do it!

Thanks!
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

bedankt Edwin!

your link made me re-think my options: it is possible to link in the DLL as a binary resource, and have the application copy this binary resource into a memory mapped file after start-up. The next step would be to have that application use memory mapped DLL's it copied there itself.

Would that be possible somehow?
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Check all of my posts here, one of them shows a way to load dll's like PEBundle.
I believe SQLite doesn't work with it..?
ebs
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

dell_jockey,

If it's OK to extract the sqlite.dll file from your executable and write it to a disk file, you can do this:

Code: Select all

;- make sure SQLite DLL is present and initialized
Procedure.l SQLiteInit() 
  ; check if SQLite DLL is present
  If FileSize("sqlite.dll") = -1
    ; not present - extract DLL and write to disk
    If OpenFile(1, "sqlite.dll")
      WriteData(?SQLite, ?SQLiteEnd-?SQLite)
      CloseFile(1)
    Else
      MessageRequester("SQLite Error", "Can't write DLL file", #MB_ICONERROR | #MB_OK)
      ProcedureReturn #False
    EndIf
  EndIf
  
  ; load/init SQLite DLL
  ProcedureReturn InitSQLite("sqlite.dll")
EndProcedure
	*
	*
	*
SQLite:
IncludeBinary "sqlite.dll"
SQLiteEnd:
It isn't quite as convenient as static linking, but it works!

Regards,
Eric
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Well, thanks for the kind words :-)

My software bundles the SQLite DLL with the EXE using some 3rd party software - it's not really statically linked after all!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

Hi Mitch,

thanks for your reply. I like Kapital a lot, so you deserve a thumbs-up!.

Edwin recommended PEbundle. Do you use the same product or could you perhaps recommend others?
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
Post Reply