Recent

Author Topic: Compiling SQLite  (Read 8913 times)

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Compiling SQLite
« on: May 09, 2013, 04:46:48 am »
Can anyone give me the commandline (windows) for compiling SQLite3 (amalgamated) with gcc.

I have searched the web for examples but the few references I find are from people that get  the same problems as me - compile errors.  I can list them, but I am sure its more that I don't know what options I need on the commandline to produce a DLL.

On a previous occasion someone created a dll with the options I needed turned on - but I  would really like to know how to do it myself and not need to rely on others to produce the dll i need.

Thanks in advance
« Last Edit: May 11, 2013, 08:49:14 am by Pascaluvr »
Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Compiling SQLite
« Reply #1 on: May 09, 2013, 08:59:41 am »
The problem is getting all the correct libraries and include files when compiling with gcc on windows. My advice: install an IDE such as wxDev-C++. That will make things much easier. It took me 5 minutes to build sqlite.dll with it.
Step by step with wxDev-c++ from http://wxdsgn.sourceforge.net/?q=node/4 :
-Create New Project, Select DLL and check 'C Project', save the project in the dir containing sqlite3.c
-Remove the 2 auto created files from the project
-Add sqlite3.c (this will take a while to parse the huge file)
-Rebuild all

That's it, your dll will be in the Output\MingW subdir.

I have attached the Makefile.win created by the IDE.

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Re: Compiling SQLite
« Reply #2 on: May 09, 2013, 10:08:51 am »
Thanks ludob - i was extremely optimistic as this was a newer version of Dev-c than i used - but still tyhe same problem.

Initially i get a problem with a malloc (forget the actual message) but something about converting a null to a integer i think.

I tried changing a few options and get :

C:\MinGW\bin\Makefile.win [Build Error]  [Objects/MingW/sqlite3.o] Error 1

Basically the same errors i get with the old Dev-c, lcc-Win and gcc commandline.

I am sure it is something basic i am doing wrong - its just frustrating.

Anyways, i have downloaded the latest sqlite and done some testing to find that the option i needed to turn on is now turned on by default - so i dont have a need just now, but I am sure it will arise in the future.

Thank you for your time and effort


Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Compiling SQLite
« Reply #3 on: May 09, 2013, 10:35:10 am »
Just download the amalgamated version, and you don't need any other option but: gcc -mdll -o sqlite3.dll sqlite3.c

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Re: Compiling SQLite
« Reply #4 on: May 09, 2013, 01:11:04 pm »
thank you thank you - that worked perfectly
Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Re: Compiling SQLite
« Reply #5 on: May 11, 2013, 09:01:26 am »
Actually I still have a problem.

While the compile works without error, I get the dreaded SIGSEGV error when its used.

This is the command line I used:

gcc -mdll -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -o sqlite3.dll sqlite3.c

The additional switches are described in:

http://www.sqlite.org/fts3.html

While I accept its probably something basically stupid that I am doing  wrong, my knowledge of C is non existent (and i guess it will stay that way)

Thanks again for any help
Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Compiling SQLite
« Reply #6 on: May 11, 2013, 12:10:19 pm »
Here it works with your defines. My little test program runs with the dll. I obviously don't know what you are trying to do;)

Add -g3 to the command line to produce debug info. gcc debug info can be used by gdb and you can simply step into the C code.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Compiling SQLite
« Reply #7 on: May 11, 2013, 12:12:50 pm »
Quote
While the compile works without error, I get the dreaded SIGSEGV error when its used.
How do you use it?

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Re: Compiling SQLite
« Reply #8 on: May 11, 2013, 03:52:30 pm »
Quote
While the compile works without error, I get the dreaded SIGSEGV error when its used.
How do you use it?

Basically just a skeleton program at this stage with the usual sqlite3connection, transaction, datasource query and dbgrid.

Its not the program at fault - i found a sqlite3.dll version that has been compiled with these  switches and it works fine.   

So while this problem isn't holding me up at this stage - it would still be useful to know for possible future requirements.

Thanks ludob, i will try the debug option tomorrow when i have more time to play with it.

Thanks for the replies.
Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Re: Compiling SQLite
« Reply #9 on: May 12, 2013, 04:15:05 am »
Just an update:

I have Win7 64bit, but i use fpc/laz 32 bit.  is it possible i have create a 64 bit dll (that would explain a SigSegV)

does gcc have a commandline switch to produce a 32 bit dll?
Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Compiling SQLite
« Reply #10 on: May 12, 2013, 07:20:37 am »
Quote
is it possible i have create a 64 bit dll (that would explain a SigSegV)
only if your gcc is 64-bit...
Quote
does gcc have a commandline switch to produce a 32 bit dll?
-m32

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Re: Compiling SQLite
« Reply #11 on: May 12, 2013, 06:19:38 pm »
mmmmhhhhhh that wasn't the problem.


ooohhhh well - hopefully i wont need other options of sqlite that need a recompile

Thanks for the help guys.
Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

bambamns

  • Full Member
  • ***
  • Posts: 226
Re: Compiling SQLite
« Reply #12 on: May 12, 2013, 09:49:45 pm »
Hi,

Do you know switch to compile it for WinCE ?

Thx
Lazarus 3.6 on Windows 11

 

TinyPortal © 2005-2018