[Qgis-developer] Buidling DBMS support for Grass and GDAL

Benjamin Ducke benjamin.ducke at ufg.uni-kiel.de
Wed Dec 12 03:02:57 EST 2007


Tisham,

did you read the attachment to my last email?

There are many little annoyances with the GDAL linking.
But they can all be rectified (at least I managed for
version 1.4.4, don't know about 1.5 yet).

I think I left out that final bit in my last email.

Here it is.
For 1.5, you will probably need to update the last bit
somewhat, since I think all user tools are now in the
"apps" subfolder.

Let me know how it's working for you.

Best,

Benjamin


-----------


Unfortunately, the GDAL configure script has some flaws on MinGW which
we need to correct. Open C:\msys\src\gdal-1.4.4\configure in a text editor.

We'll need to fix the check for PostgreSQL. Locate the line (around nr.
21800):

LIBS="-L`$PG_CONFIG --libdir` -lpq"

... and replace it with:

LIBS="-L/usr/lib -lpq"

Likewise, replace the lines (around 21873)

LIBS="-L`$PG_CONFIG --libdir` -lpq"

PG_INC="-I`$PG_CONFIG --includedir` -I`$PG_CONFIG --includedir-server`"

... with:

LIBS="-L /usr/lib -lpq"

PG_INC="-I/usr/local/include -I/usr/local/include/postgresql/server"

(Note: the reason for this is that somehow the `$PG_CONFIG` statement
does not produce a correct string, so we have to insert the information
manually!)

Use the following line to compile a version that includes all
capabilities mentioned in these instructions (provided that you have
installed everything up to here):


./configure --prefix=/usr --bindir=/usr/local/bin --host=mingw32
--without-libtool --with-pg=/usr/local/bin/pg_config.exe
--with-mysql=/usr/local/mysql/scripts/mysql_config --with-xerces
--with-xerces-lib="-L/usr/local/lib -lxerces-c -DXML_LIBRARY"
--with-odbc=/mingw --with-sqlite=/usr --with-geos=/usr/bin/geos-config
--without-python


Unfortunately, this is not all. Some of the Makefiles generated by the
configure script will be flawed and we need to hand-edit again!

In order to link the system ODBC libraries with GDAL, you need to edit
C:\msys\src\gdal-1.4.4\GDALmake.opt a bit. Find the line that defines
``LIBS='' at the start of the file. After the item ``-L/mingw/lib'',
delete the lib items `` -lodbc'' and ``-lodbcinst'' and add ``-lodbc32
-lodbccp32'' instead to correctly configure the ODBC libraries on MinGW:

LIBS = ... -L/mingw -L/mingw/lib -lodbc32 -lodbccp32

Note: re-running the configure script will reset GDALmake.opt to its
original content, so the changes above must be repeated!

For Xerces support, edit
C:\msys\1.0\src\gdal-1.4.4\ogr\ogrsf_frmts\ili\iom\GNUmakefile and edit
the ``CPPFLAGS'' definition:

CPPFLAGS        := -DXML_LIBRARY $(XERCES_INCLUDE) $(CPPFLAGS)

We also need to edit some of the Xerces-C related source code. Open
C:\msys\1.0\src\gdal-1.4.4\ogr\ogrsf_frmts\ili\iom\iom_utilities.cpp and
rename the _searchenv () function so it does not collide with MinGW's
own version. Change the line (ca. 56):

static void _searchenv(const char *name, const char *envname, char *hitfile)

to:

static void _searchenv2(const char *name, const char *envname, char
*hitfile)

In addition, open both
C:\msys\1.0\src\gdal-1.4.4\ogr\ogrsf_frmts\gml\GNUmakefile and
C:\msys\1.0\src\gdal-1.4.4\ogr\ogrsf_frmts\ili\GNUmakefile in your text
editor and add ``-DXML_LIBRARY'' to the lines defining ``CPPFLAGS'':

CPPFLAGS := -DXML_LIBRARY -I.. -I../.. $(GDAL_INCLUDE)

When all is fixed, compile the software:

make
make install

Finally, edit two lines in the file c:\msys\usr\local\bin\gdal-config.
This is necessary to make the GRASS configure script work later on.
Here, every library that was linked to GDAL as part of its feature set
needs to be mentioned following an -l switch. Make sure that all
external libraries are referenced properly (note: ``CONFIG_DEP_LIBS=''
should contain the same items as ``CONFIG_LIBS='', except for ``-lgdal''
itself):


CONFIG_LIBS="-L/usr/lib -L/usr/local/lib -L/usr/local/mysql/bin/ -lgdal
-lz -ltiff -lpq -lmysqlclient -lxerces-c -DXML_LIBRARY -lodbc32
-lodbccp32 -lsqlite3 -lgeos_c"

CONFIG_DEP_LIBS="-L/usr/lib -L/usr/local/lib -L/usr/local/mysql/bin/ -lz
-ltiff -lpq -lmysqlclient -lxerces-c -DXML_LIBRARY -lodbc32 -lodbccp32
-lsqlite3 -lgeos_c"

Now, we need to put in some extra work to make the Windows shared DLLs
and link the GDAL tools with them. Note: some of these are very long
command lines. I have put in some extra spaces, so it is easier to see
what commands need to be pasted as one line. First, delete the static
copy of the GDAL library (important: GRASS configure script will
otherwise fail to detect GDAL correctly!):

rm /usr/lib/libgdal.a

In the next step, we do the actual linking to create the shared DLL.
Make sure that you have the gdal-config script in your executable path
at this point and that issuing a:

gdal-config --libs

Will give you a list of all the libraries which GDAL tools need to be
linked against. Now continue building the shared GDAL library and the tools:

g++ -s -shared -o ./libgdal.dll ./frmts/o/*.o ./gcore/*.o ./port/*.o
./alg/*.o ./ogr/ogrsf_frmts/o/*.o ./ogr/ogrgeometryfactory.o
./ogr/ogrpoint.o ./ogr/ogrcurve.o ./ogr/ogrlinestring.o
./ogr/ogrlinearring.o ./ogr/ogrpolygon.o ./ogr/ogrutils.o
./ogr/ogrgeometry.o ./ogr/ogrgeometrycollection.o
./ogr/ogrmultipolygon.o ./ogr/ogrsurface.o ./ogr/ogrmultipoint.o
./ogr/ogrmultilinestring.o ./ogr/ogr_api.o ./ogr/ogrfeature.o
./ogr/ogrfeaturedefn.o ./ogr/ogrfeaturequery.o ./ogr/ogrfeaturestyle.o
./ogr/ogrfielddefn.o ./ogr/ogrspatialreference.o ./ogr/ogr_srsnode.o
./ogr/ogr_srs_proj4.o ./ogr/ogr_fromepsg.o ./ogr/ogrct.o ./ogr/ogr_opt.o
./ogr/ogr_srs_esri.o ./ogr/ogr_srs_pci.o ./ogr/ogr_srs_usgs.o
./ogr/ogr_srs_dict.o ./ogr/ogr_srs_panorama.o ./ogr/swq.o
./ogr/ogr_srs_validate.o ./ogr/ogr_srs_xml.o ./ogr/ograssemblepolygon.o
./ogr/ogr2gmlgeometry.o ./ogr/gml2ogrgeometry.o `gdal-config --dep-libs`

install libgdal.dll /usr/lib
install libgdal.dll /usr/local/bin

cd ogr
g++ -s ogrinfo.o -o ogrinfo.exe `gdal-config --libs`
g++ -s ogr2ogr.o -o ogr2ogr.exe `gdal-config --libs`
g++ -s ogrtindex.o -o ogrtindex.exe `gdal-config --libs`
install ogrinfo.exe ogr2ogr.exe ogrtindex.exe /usr/local/bin
cd ../apps
g++ -s gdalinfo.o -o gdalinfo.exe `gdal-config --libs`
g++ -s gdal_translate.o -o gdal_translate.exe `gdal-config --libs`
g++ -s gdaladdo.o -o gdaladdo.exe `gdal-config --libs`
g++ -s gdalwarp.o -o gdalwarp.exe `gdal-config --libs`
g++ -s gdal_contour.o -o gdal_contour.exe `gdal-config --libs`
g++ -s gdaltindex.o -o gdaltindex.exe `gdal-config --libs`
g++ -s gdal_rasterize.o -o gdal_rasterize.exe `gdal-config --libs`

install gdalinfo.exe gdal_translate.exe gdaladdo.exe gdalwarp.exe
gdal_contour.exe gdaltindex.exe gdal_rasterize.exe /usr/local/bin


-----------



Tisham Dhar wrote:
> Hi All,
> 
> Thanks a lot for all the pointer regarding DBMS support building. I have
> grass built with ODBC, Sqlite, MySQL and PostgreSQL. GDAL is being more
> of a problem and would not link with these dbms drivers enabled. I have
> undefined symbol linker errors even if the initial detection succeeds.
> Any ideas about fixing these are welcome. Otherwise I am going to
> release with what I have now.
> 
> Regards,
> 
> Tishampati Dhar
> 
>  Software Developer
> 
>  APOGEE IMAGING INTERNATIONAL
> 
>  Building 12B
> 
>  1 Adelaide - Lobethal Road 
> 
>  Lobethal SA 5241 
> 
>   Telephone: +61 - 8 - 8389 5499
> 
>  Fax: +61 - 8 - 8389 5488
> 
>  Mobile: +61 - 406114165
> 
> Email: tisham at apogee.com.au mailto:tisham at apogee.com.au>
> 
> Web: www.apogee.com.au <http://www.apogee.com.au> 
> 
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> "The information in this e-mail may be confidential and/or commercially
> privileged. It is intended solely for the addressee. Access to this
> e-mail by anyone else is unauthorised. If you are not the
> intendedrecipient, any disclosure, copying, distribution or action taken
> or omitted to be taken in reliance on it, is prohibited and may be
> unlawful."
> 
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.qgis.org
> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
> 
> 

-- 
Benjamin Ducke, M.A.
Archäoinformatik
(Archaeoinformation Science)
Institut für Ur- und Frühgeschichte
(Inst. of Prehistoric and Historic Archaeology)
Christian-Albrechts-Universität zu Kiel
Johanna-Mestorf-Straße 2-6
D 24098 Kiel
Germany

Tel.: ++49 (0)431 880-3378 / -3379
Fax : ++49 (0)431 880-7300
www.uni-kiel.de/ufg




More information about the Qgis-developer mailing list