Build using msvc

87 views
Skip to first unread message

Wuping Xin

unread,
May 26, 2021, 5:14:45 PM5/26/21
to SpatiaLite Users
I downloaded the latest spatialite source, and tried to build using msvc 2019.

I found the following two files 

-  they should include the following two lines in the Clean section:
del src\control_points\*.obj
del src\geopackage\*.obj

Otherwise,  after building x86,  the remnant *.obj file (which is of format 32 bit) would prevent a successful x64 build.

Thanks.
Wuping

David Hoogenbosch

unread,
Jun 1, 2021, 6:12:57 AM6/1/21
to SpatiaLite Users
Hello Wuping,

I've been trying to build spatialite using msvc (to use it in a c# project with system.data) and have not been able to make it work.
I've build sqlite, librttopo and geos but get stuck on the proj dependency.
When building proj (6.3.2) I get get a "proj_d.lib" file. While spatialite fails to link because it is missing "proj_i.lib".
I get the feeling I have taken a wrong turn somewhere because building has been a pain at every turn.

How did you do it?

Thanks,
David

Wuping Xin

unread,
Jun 1, 2021, 10:06:04 AM6/1/21
to SpatiaLite Users, Wuping Xin
Hi David,

proj_d.lib is the (debug version) of the import lib.  I didn't build proj from scratch using source code.  Actually, I directly use OSGeo4w to install proj, Geos, Sqlite3, FreeXl, iconv, and ZLib - because the installer will install those dependencies to C:/OSGeo4w, with proper include and lib folder set up to match what have been defined in Spatialite make file (so you don't need to change the make file, just use as is)

-  Download OSGeo4w (32bit) from this link http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe ,  or 64bit from this link: http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe

-  Directly run the osgeo4W installer downloaded from the above links,  choose: "Advanced Install"

- Then install the respective dependencies using the "Search" edit, and install the respective dependencies.


- The next step would be to install librttop manually.  Go to this link to download librttopo: http://www.gaia-gis.it/gaia-sins/librttopo-1.1.0.zip.  Use the attached corrected makefiles.
    - cd librttopo-1.1.0
    - nmake /f makefile.vc    // <---- this will build the lib and dll
    - nmake /f makefile.vc install  // <---  this will copy the lib and dll to proper OSGeo4W folder
    - nmake/f  makefile.vc clean  // <--- this will delete the file generated in the above build process. It is necessary if you would like to install 64bit of spatialite subsequently.

- Build spatialite manually.  Go to this link to download spatialite source: http://www.gaia-gis.it/gaia-sins/libspatialite-5.0.1.zip  . Use the attached corrected makefiles.
    - cd libspatialite-5.0.1
    - nmake /f makefile.vc    // <---- this will build the lib and dll
    - nmake /f makefile.vc install  // <---  this will copy the lib and dll to proper OSGeo4W folder
    - nmake/f  makefile.vc clean  // <--- this will delete the file generated in the above build process. It is necessary if you would like to install 64bit of spatialite subsequently.

That is it.  I have been successful building spatialite 5.0.1 using Visual Studio 2019.  I have also made it work with C++ Builder.   I run the spatialite demos (in C), and everything looks fine.

If you encountered any issues,  feel free to let me know.

Best
Wuping
--
You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialite-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spatialite-users/bed1499b-b598-4c52-a64c-89bb41b16d92n%40googlegroups.com.
librttopo-make-files.zip
spatialite-makefiles.zip

a.fu...@lqt.it

unread,
Jun 2, 2021, 3:36:57 AM6/2/21
to spatiali...@googlegroups.com
On Tue, 1 Jun 2021 03:12:57 -0700 (PDT), David Hoogenbosch wrote:
> Hello Wuping,
>
> I've been trying to build spatialite using msvc (to use it in a c#
> project with system.data) and have not been able to make it work.
> I've build sqlite, librttopo and geos but get stuck on the proj
> dependency.
> When building proj (6.3.2) I get get a "proj_d.lib" file. While
> spatialite fails to link because it is missing "proj_i.lib".
> I get the feeling I have taken a wrong turn somewhere because
> building
> has been a pain at every turn.
>

Hi David,

just a first remark: please notice that proj 6.3.2 is obsolete
nowadays, the current updated version is 8.0.1 released last
month.

second remark: there ara basically two alternative approaches
for building lisbaptiatilite on Windows platforms:

1. using the MinGW compiler on the MSYS2 shell.
this is a very decent emulator of the development
environment typical of Linux, and will make easier
and painless building open source libraries.
This one is the solution adopted by SpatiaLite
itself for building its own binary packages for
Windows, and you'll find very detailed and
frequently updated "recipes" from here:

32-bit:
http://www.gaia-gis.it/gaia-sins/mingw32_how_to.html

64-bit
http://www.gaia-gis.it/gaia-sins/mingw64_how_to.html


2. alternatively you can use the MSVC compiler.
in this case (as already reported by Wuping)
you simply have to use "nmake" using one
of the two MSVC Makefiles contained into the
sources tarball (makefile.vc or makefile64.vc)
and installing all the other depending precompiled
libraries (PROJ, GEOS etc) from the standard
OSGeo4w distribution.

attempting to build from scratch the complete
pile of depending libraries using the MSVC
compiler will surely be a long and tiring
affair (and presumably frustrating), bacause
many of them are mainly intended for Linux
and will almost certainly require to apply
several manual patches in order to build
smoothly on Windows.

dowloading the pre-built libraries from OSGeo4w
will surely make easier and faster your work.

bye Sandro

Jürgen E. Fischer

unread,
Jun 2, 2021, 4:27:22 AM6/2/21
to spatiali...@googlegroups.com
Hi Wuping,

On Wed, 26. May 2021 at 14:14:45 -0700, Wuping Xin wrote:
> I downloaded the latest spatialite source, and tried to build using msvc
> 2019.

osgeo4w testing has spatialite built with msvc 2019 using the recipe from

https://github.com/jef-n/OSGeo4W/tree/master/src/libspatialite/osgeo4w


Jürgen

--
Jürgen E. Fischer norBIT GmbH Tel. +49-4931-918175-31
Dipl.-Inf. (FH) Rheinstraße 13 Fax. +49-4931-918175-50
Software Engineer D-26506 Norden https://www.norbit.de
signature.asc
Pflichtangaben

David Hoogenbosch

unread,
Jun 2, 2021, 11:10:46 AM6/2/21
to SpatiaLite Users
So I definitely did take the wrong turn. Building following OSGeo installer method was painless.
Thanks everyone.
Reply all
Reply to author
Forward
0 new messages