我一直在尝试过去2天在我的Mac上安装IP2Location。 我设法安装IP2Location C库,现在PECL extesion正在引发问题。
我跑了phpize,然后'sudo ./configure',我得到以下错误:
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.xx is required or library not found
我正在使用最新版本的IP2Location,所以我知道这是正确的版本。
有人可以澄清这个错误吗?
我看了一下config.log,发现这是最后一个错误:
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.xx is required or library not found
我已经检查并确认/usr/local/lib/libIP2Location.so存在。
运行“文件”给出以下内容:
$ file libIP2Location.so libIP2Location.so: Mach-O 64-bit bundle x86_64
这不是你,这是代码…
IP2Location C库显式构build一个包(也称为可加载模块),但不是共享库。 在构build时链接到一个包是一个可爱的小窍门,它可以在包的构build树中执行GNU libtool脚本,但通常其他程序只能在运行时加载包。 Thge C库源也build立一个静态库,这个PECL扩展可以在编译时链接进来,但是它不会这样做。 同一个人维护这两个软件包,所以你可能可以通过提醒他解决问题来解决这个问题。 这样做的地方将是其中之一:
https://github.com/chrislim2888/IP2Location-PECL-Extension/issues https://github.com/chrislim2888/IP2Location-C-Library/issues
我认为后者,因为这看起来像一个在C库的构build过程中,有一堆废弃的automake指令的错误,任意添加/ opt / lib /(在大多数Mac上不存在)到库searchpath,并build立一个“testing”程序,当通过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
你也许可以通过摆弄C库源代码中的自动工具文件来修复一个真正的共享库,或者(也许)弄清楚如何使用libtool来完成PECL扩展的链接,但是我不会build议做法。
另一种select:支持IP2Location的PHP绑定是PHP模块,而不是PECL扩展:
https://www.ip2location.com/developers/php
这可能与C库的模块或静态库一起工作。
在IP2Location-C-Library中进行以下更改并从头开始重新安装。 (sh build.sh)。
并重新编译你的PECL。 请让我也知道结果。
diff --git a/Makefile.am b/Makefile.am index 37a4714..491c0bd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,3 @@ NULL = -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 \ IP2Loc_DBInterface.c -libIP2Location_la_LDFLAGS = -module -no-undefined -version-info 1:0:0 +libIP2Location_la_LDFLAGS = -no-undefined -version-info 1:0:0