I've been trying for the past 2 days to install IP2Location on my Mac. I've managed to install IP2Location C Library, now PECL extesion is causing issues.

I've ran phpize and then 'sudo ./configure' and I get the following error:

checking for ip2location support... yes, shared
checking for ip2location files in default path... found in /usr/local
checking for IP2Location_open_mem in -lIP2Location... no
configure: error: wrong ip2location, lib version >= 6.x.x is required or library not found

I'm using the latest version of IP2Location, so I know it's the right version.

Can someone shed some light on this error?

I had a look into config.log and found this as the last error:

227 configure:4112: checking for ip2location files in default path
228 configure:4117: result: found in /usr/local
229 configure:4269: checking for IP2Location_open_mem in -lIP2Location
230 configure:4294: cc -o conftest -g -O2  -Wl,-rpath,/usr/local/lib -L/usr/local/lib  conftest.c -lIP2Location   >&5
231 ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file '/usr/local/lib/libIP2Location.so' for architecture x86_64
232 clang: error: linker command failed with exit code 1 (use -v to see invocation)
233 configure:4294: $? = 1
234 configure: failed program was:
235 | /* confdefs.h */
236 | #define PACKAGE_NAME ""
237 | #define PACKAGE_TARNAME ""
238 | #define PACKAGE_VERSION ""
239 | #define PACKAGE_STRING ""
240 | #define PACKAGE_BUGREPORT ""
241 | #define PACKAGE_URL ""
242 | /* end confdefs.h.  */
243 |
244 | /* Override any GCC internal prototype to avoid an error.
245 |    Use char because int might match the return type of a GCC
246 |    builtin and then its argument prototype would still apply.  */
247 | #ifdef __cplusplus
248 | extern "C"
249 | #endif
250 | char IP2Location_open_mem ();
251 | int
252 | main ()
253 | {
254 | return IP2Location_open_mem ();
255 |   ;
256 |   return 0;
257 | }
258 configure:4304: result: no
259 configure:4419: error: wrong ip2location, lib version >= 6.x.x is required or library not found

I've checked and can confirm that /usr/local/lib/libIP2Location.so exists.

Run 'file' gives the following:

$ file libIP2Location.so
libIP2Location.so: Mach-O 64-bit bundle x86_64

2 Answers 2


It's not you, it's the code...

The IP2Location C library explicitly builds a bundle (a.k.a. loadable module) but not a shared library. Linking against a bundle at build time is a cute trick that the GNU libtool script in the bundle's build tree can do but generally other programs can only load bundles at run time. Thge C library source also builds a static library, which the PECL extension COULD link in at build time, but it doesn't try that. The same person maintains both packages, so you probably can get it fixed by alerting him to the problem. The places to do so would be one of these:

https://github.com/chrislim2888/IP2Location-PECL-Extension/issues https://github.com/chrislim2888/IP2Location-C-Library/issues

I'd argue for the latter, as this looks to me like a bug in the build process of the C library, which has a bunch of deprecated automake directives, arbitrarily adds /opt/lib/ (nonexistent on most Macs) to the library search path, and builds a 'test' program which generates a telling warning when linked by libtool:

/bin/sh ../libtool  --tag=CC   --mode=link gcc  -I/usr/include/malloc -no-cpp-precomp  -L/opt/lib -o test-IP2Location test-IP2Location.o ../libIP2Location/libIP2Location.la 

*** Warning: Linking the executable test-IP2Location against the loadable module
*** libIP2Location.so is not portable!
*** Warning: lib libIP2Location.so is a module, not a shared library

You could maybe hack in a fix by fiddling with the autotools files in the C library's source and rebuilding a real shared library OR (maybe) figuring out how to use libtool to do the link of the PECL extension, but I wouldn't advise either approach.

Another option: the supported PHP binding for IP2Location is a PHP module, not a PECL extension:


That MIGHT work with the C library's module or static library.


Make the below changes in IP2Location-C-Library and install it again with from scratch. (sh build.sh).

And recompile your PECL. Please let me also know the results.

diff --git a/Makefile.am b/Makefile.am
index 37a4714..491c0bd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,3 @@
-INCLUDES = -Wall -ansi
+AM_CPPFLAGS = -Wall -ansi
 SUBDIRS =      libIP2Location  test    $(NULL)
diff --git a/libIP2Location/Makefile.am b/libIP2Location/Makefile.am
index 4bc5854..ed00358 100644
--- a/libIP2Location/Makefile.am
+++ b/libIP2Location/Makefile.am
@@ -9,4 +9,4 @@ include_HEADERS = IP2Location.h IP2Loc_DBInterface.h
 libIP2Location_la_SOURCES = IP2Location.c \

-libIP2Location_la_LDFLAGS = -module -no-undefined -version-info 1:0:0 
+libIP2Location_la_LDFLAGS = -no-undefined -version-info 1:0:0 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.