Difference between revisions of "Build SQLite extension on windows"

From GRASS-Wiki
Jump to navigation Jump to search
(Created page with "In [http://grass.osgeo.org/grass71/manuals/v.db.update.html v.db.update] there is following option: ''sqliteextra=name Name of SQLite extension file for extra functions (...")
 
m (+crossref)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
In [http://grass.osgeo.org/grass71/manuals/v.db.update.html v.db.update] there is following option:
'''Problem:''' SQLite lacks by default log(), sqrt(), and other functions.


''sqliteextra=name
'''Solution:''' In {{cmd|v.db.update}} there is the following option:
 
    ''sqliteextra=name
     Name of SQLite extension file for extra functions (SQLite backend only)''
     Name of SQLite extension file for extra functions (SQLite backend only)''


For build SQLite extension for winGRASS follow these steps:
* Install the OSGeo4W directory structure as a build environment by these [http://trac.osgeo.org/grass/wiki/CompileOnWindows#InstalltheOSGeo4Wdirectorystructure instructions]
* Download '''extension-functions.c''' from [https://www.sqlite.org/contrib here] and save the file in a folder of your OSGeo4W build environment (e.g. ''C:\OSGeo4Wdev\src\sqliteextension'')
* Download the SQLite source from [https://www.sqlite.org/download.html here], unzip the archive and copy '''sqlite3.h''' and '''sqlite3ext.h''' in the folder of the step before (e.g. ''C:\OSGeo4Wdev\src\sqliteextension'')
* Open the '''MSYS Shell''' offered by your OSGeo4W build environment and change to the SQLite extension directory by e.g. ''cd "C:\OSGeo4Wdev\src\sqliteextension"'' (double quotes are needed in the MSYS Shell)
* Then type in the MSYS Shell following command: '''gcc -fPIC -lm -shared extension-functions.c -o libsqlitefunctions.dll'''
Then '''libsqlitefunctions.dll''' is built and can be used by v.db.update (example from the manual):
    g.copy vect=precip_30ynormals,myprecip_30ynormals
    v.db.addcolumn myprecip_30ynormals column="logjuly double precision"
    v.db.update myprecip_30ynormals column="logjuly" query_column="log(jul)" \
      sqliteextra=C:\OSGeo4Wdev\src\sqliteextension\libsqlitefunctions.dll
=== See also ===


* [[Build SQLite extension on Linux]]


[[Category:FAQ]]
[[Category:FAQ]]
[[Category:Vector]]

Latest revision as of 10:47, 12 March 2017

Problem: SQLite lacks by default log(), sqrt(), and other functions.

Solution: In v.db.update there is the following option:

   sqliteextra=name
   Name of SQLite extension file for extra functions (SQLite backend only)

For build SQLite extension for winGRASS follow these steps:

  • Install the OSGeo4W directory structure as a build environment by these instructions
  • Download extension-functions.c from here and save the file in a folder of your OSGeo4W build environment (e.g. C:\OSGeo4Wdev\src\sqliteextension)
  • Download the SQLite source from here, unzip the archive and copy sqlite3.h and sqlite3ext.h in the folder of the step before (e.g. C:\OSGeo4Wdev\src\sqliteextension)
  • Open the MSYS Shell offered by your OSGeo4W build environment and change to the SQLite extension directory by e.g. cd "C:\OSGeo4Wdev\src\sqliteextension" (double quotes are needed in the MSYS Shell)
  • Then type in the MSYS Shell following command: gcc -fPIC -lm -shared extension-functions.c -o libsqlitefunctions.dll

Then libsqlitefunctions.dll is built and can be used by v.db.update (example from the manual):

   g.copy vect=precip_30ynormals,myprecip_30ynormals
   v.db.addcolumn myprecip_30ynormals column="logjuly double precision"
   v.db.update myprecip_30ynormals column="logjuly" query_column="log(jul)" \
     sqliteextra=C:\OSGeo4Wdev\src\sqliteextension\libsqlitefunctions.dll


See also