Problem Building spatialite-tools-3.1.0b on Mac OS X

701 views
Skip to first unread message

Chris White

unread,
Jul 17, 2012, 11:41:40 PM7/17/12
to spatiali...@googlegroups.com
Hi all,

I'm somewhat new to spatialite in general. Not a Unix guru, but know enough to be dangerous. :D

Anyhoo, I'm trying to build spatialite-tools-3.1.0b on my Mac (running Lion). I've downloaded and built and installed all of the prerequisites, but when I try to run ./configure for spatialite-tools-3.1.0b I always get the following error even though I was able to successfully make and install spatialite (libspatialite-3.0.1):

checking for LIBSPATIALITE... no
configure: error: 'libspatialite' is required but it doesn't seem to be installed on this system.

Any info would be greatly appreciated. Banging my head against the wall at this point.

Chris

Noli Sicad

unread,
Jul 18, 2012, 3:00:54 AM7/18/12
to spatiali...@googlegroups.com
Chris,

I have not any spatialite compiling yet in Lion. However, try to
location where is the libspatialite is installed.

I think you can configure the spatialite and libspatialite installation.

By default I think Sandro install the spatialite in /opt/, if I can
remember right.

See this archive : "compiling on mac osx lion"
https://groups.google.com/forum/#!msg/spatialite-users/QwbgkKo-5pE/_PmkX8n1OF8J

Noli
> --
> You received this message because you are subscribed to the Google Groups
> "SpatiaLite Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/spatialite-users/-/Xk3Fp7O2T2cJ.
> To post to this group, send email to spatiali...@googlegroups.com.
> To unsubscribe from this group, send email to
> spatialite-use...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/spatialite-users?hl=en.
>
>

Brad Hards

unread,
Jul 18, 2012, 3:41:49 AM7/18/12
to spatiali...@googlegroups.com, Chris White
On Wednesday 18 July 2012 13:41:40 Chris White wrote:
> checking for LIBSPATIALITE... no
> configure: error: 'libspatialite' is required but it doesn't seem to be
> installed on this system.
This message comes from the bit of configure that looks like:
PKG_CHECK_MODULES([LIBSPATIALITE], [spatialite], , AC_MSG_ERROR(['libspatialite' is required but it doesn't seem to be installed on this system.]))

So there are a few reasons why pkg-config might not be able
to find the libspatialite installation.

Two things to start off checking:
1. Do you actually have pkg-config installed? You should see it
in the configure logs and command line output just before
the error. You should see something like:
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes

2. Try running pkg-config on the command line. Something like:
pkg-config --libs spatialite
should result in something like:
-L/usr/local/lib -lspatialite -lsqlite3 -lm
(or -L/opt/lib if that is where you installed to)

If you get something like:
Package spatialite was not found in the pkg-config search path.
Perhaps you should add the directory containing `spatialite.pc'
to the PKG_CONFIG_PATH environment variable
then you haven't set up pkg-config correctly - just follow the
instructions in the error.

Brad

Chris White

unread,
Jul 18, 2012, 9:40:42 AM7/18/12
to spatiali...@googlegroups.com
Thanks Noli!

Chris White

unread,
Jul 18, 2012, 9:42:40 AM7/18/12
to spatiali...@googlegroups.com
Spot on Brad. That was the issue. I had already installed pkg-config, but hadn't setup the environment variable for it. Wish I could give you a +1 or something. :)

So, I got the ./configure to run, but now I get a linker error when I run make:

make  all-am
/bin/sh ./libtool --tag=CC   --mode=link gcc  -g -O2   -o spatialite shell.o -L/usr/local/lib -lspatialite -lsqlite3 -lm -L/usr/local/lib -lfreexl -lm -lreadline -lcurses  -lproj -lexpat 
libtool: link: gcc -g -O2 -o spatialite shell.o  -L/usr/local/lib /usr/local/lib/libspatialite.dylib -L/opt/local/lib -lpthread -ldl /opt/local/lib/libiconv.dylib /usr/local/lib/libgeos_c.dylib /usr/local/lib/libgeos.dylib -lsqlite3 /usr/local/lib/libfreexl.dylib /usr/local/lib/libiconv.dylib -lreadline -lcurses /usr/local/lib/libproj.dylib -lm /opt/local/lib/libexpat.dylib
Undefined symbols for architecture x86_64:
  "_sqlite3_enable_load_extension", referenced from:
      _open_db in shell.o
  "_iconv", referenced from:
      _convert_from_utf8 in shell.o
      _process_input in shell.o
  "_iconv_close", referenced from:
      _do_meta_command in shell.o
      _process_input in shell.o
  "_iconv_open", referenced from:
      _do_meta_command in shell.o
      _process_input in shell.o
  "_sqlite3_load_extension", referenced from:
      _do_meta_command in shell.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [spatialite] Error 1
make: *** [all] Error 2

Any thoughts? I just downloaded and built libiconv to see if that would get rid of some of the linker errors but no dice. A bit lost. 

--
You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.

Chris White

unread,
Jul 18, 2012, 10:06:43 AM7/18/12
to spatiali...@googlegroups.com
OK so I got rid of the sqlite linker errors by downloading and making/installing a new version of sqlite. Looking into the iconv linker issue, but if anyone has any thoughts I would be grateful.

Chris White

unread,
Jul 18, 2012, 10:40:18 AM7/18/12
to spatiali...@googlegroups.com
OK got it. The key is to run:

- ./configure --prefix=/usr/local


:)

a.fu...@lqt.it

unread,
Jul 18, 2012, 10:43:31 AM7/18/12
to spatiali...@googlegroups.com
Hi Charlie,

> Undefined symbols for architecture x86_64:
> "_sqlite3_enable_load_extension", referenced from:
> _open_db in shell.o
> OK so I got rid of the sqlite linker errors by downloading and
> making/installing a new version of sqlite.
>

all right; this is because the standard (aka system) libsqlite
shipped is Mac Os X always disables dynamic extensions loading.
in other words, if you absolutely need a libsqlite supporting
dynamic extension (an absolute pre-requisite for spatialite)
then you absolutely need to build libsqlite by yourself.
(or you can install it from MacPorts, HomeBrew and alike)


> Looking into the iconv linker issue, but if anyone has any thoughts I
> would be grateful.
>
> libtool: link: gcc -g -O2 -o spatialite shell.o  -L/usr/local/lib
> /usr/local/lib/libspatialite.dylib -L/opt/local/lib -lpthread -ldl
> /opt/local/lib/libiconv.dylib /usr/local/lib/libgeos_c.dylib
> /usr/local/lib/libgeos.dylib -lsqlite3
> /usr/local/lib/libfreexl.dylib /usr/local/lib/libiconv.dylib
> -lreadline -lcurses /usr/local/lib/libproj.dylib -lm
> /opt/local/lib/libexpat.dylib
> Undefined symbols for architecture x86_64:
>   "_iconv", referenced from:
>       _convert_from_utf8 in shell.o
>       _process_input in shell.o
>   "_iconv_close", referenced from:
>       _do_meta_command in shell.o
>       _process_input in shell.o
>   "_iconv_open", referenced from:
>       _do_meta_command in shell.o
>       _process_input in shell.o
>

this is a little bit harder to explain; few useful hints:
- libiconv comes in a lot of different "flavors"
- actual API symbols widely vary from one flavor to the other
- e.g. on my own Windows libiconv.a there is no "_iconv_open"
symbol at all; there is a "_libiconv_open" instead
- any magical name translation is performed by few conditional
macros defined in the "iconv.h" header file. e.g.
#ifndef LIBICONV_PLUG
#define iconv_close libiconv_close
#endif

conclusion: you are probably including an iconv.h header not
corresponding to the library you are effectively attempting
to link; or there is some mismatching definition in your own
configuration.

-----------------

last but not least: be warned.
as several users have already reported, the Mac Os X Lion
C compiler is buggish; it's very probable that you'll experience
some "crazy" behavior when using any R*Tree Spatial Index.
Building libspatialite and libsqlite disabling at all any
code optimization "-O0" seems to effectively resolve this
unpleasant issue.

bye Sandro

--
Il messaggio e' stato analizzato alla ricerca di virus o
contenuti pericolosi da MailScanner, ed e'
risultato non infetto.

Christopher White

unread,
Jul 18, 2012, 10:52:48 AM7/18/12
to spatiali...@googlegroups.com
Thanks Sandro. Incredibly helpful. Really appreciate the extra background info.

Noli Sicad

unread,
Aug 10, 2012, 11:02:32 PM8/10/12
to spatiali...@googlegroups.com, Chris White
Hi Chris,
I don't know what Mac OS X you are using but I think it does not
matter if it is Snow Leopard, Lion or Mountain Lion.

iconv library is the problem.

1. Download and Install iconv using configure, make and install.

2. ./configure in spatialite-tools

3. Edit Makefile in spatialite-tools directory / folder and add:

(The current entry is blank (i.e. LDFLAGS = ))

LDFLAGS = -liconv

4. make
5. make install

This will solve the problem. I figured it out in Mountain Lion (10.8)
using libspatialite and spatialite-tools "trunk)" posted earlier in
the ML.

Noli

Charlie Sharpsteen

unread,
Dec 4, 2012, 11:34:14 PM12/4/12
to spatiali...@googlegroups.com
Just a general note that libspatialite, spatialite-tools and spatialite-gui are all available from the Homebrew package manager. We build against recent versions of SQLite that have both RTree and dynamic extensions enabled and are compiled with safe levels of optimization. Iconv issues are taken care of as well.

-Charlie
Reply all
Reply to author
Forward
0 new messages