在 Windows 上安装 GeoIP-Python 时出错

发布于 2024-10-24 20:21:52 字数 4812 浏览 2 评论 0原文

我正在尝试在 Windows 7 上安装 GeoIP-Python-1.2.4。 在此之前,我需要安装 GeoIP-1.4.6。 我正在使用 README.MinGW 说明进行安装。我使用MinGW并通过./configure。当我执行“make”时,出现以下错误:

*** Warning: This system can not link to static lib archive libGeoIP.la.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.
libtool: link: warning: undefined symbols not allowed in i686-pc-mingw32 shared
libraries
ar cru .libs/libGeoIPUpdate.a  GeoIPUpdate.o md5.o
ranlib .libs/libGeoIPUpdate.a
creating libGeoIPUpdate.la
(cd .libs && rm -f libGeoIPUpdate.la && cp -p ../libGeoIPUpdate.la libGeoIPUpdat
e.la)
make[1]: Leaving directory `/home/Harp/GeoIP-1.4.6/libGeoIP'
Making all in apps
make[1]: Entering directory `/home/Harp/GeoIP-1.4.6/apps'
gcc -DPACKAGE_NAME=\"GeoIP\" -DPACKAGE_TARNAME=\"GeoIP\" -DPACKAGE_VERSION=\"1.4
.6\" -DPACKAGE_STRING=\"GeoIP\ 1.4.6\" -DPACKAGE_BUGREPORT=\"[email protected]
\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -
DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE
_STDINT_H=1 -DHAVE_UNISTD_H=1 -D__EXTENSIONS__=1 -D_ALL_SOURCE=1 -D_GNU_SOURCE=1
 -D_POSIX_PTHREAD_SEMANTICS=1 -D_TANDEM_SOURCE=1 -DPACKAGE=\"GeoIP\" -DVERSION=\
"1.4.6\" -DLITTLE_ENDIAN_HOST=1 -DHAVE_STDINT_H=1 -DHAVE_ZLIB_H=1 -DHAVE_GETTIME
OFDAY=1 -DHAVE_VSNPRINTF=1 -DHAVE_VSPRINTF=1 -I. -I../libGeoIP -Wall -DSYSCONFDI
R=\"/usr/local/etc\" -Wall   -O3 -I/usr/local/include -c geoiplookup.c
/bin/sh ../libtool --tag=CC   --mode=link gcc  -O3 -I/usr/local/include  -L/usr/
local/lib -lwsock32 -o geoiplookup.exe geoiplookup.o ../libGeoIP/libGeoIP.la
mkdir .libs
gcc -O3 -I/usr/local/include -o geoiplookup.exe geoiplookup.o  -L/usr/local/lib
../libGeoIP/.libs/libGeoIP.a -lwsock32
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x8af): undefined reference
 to `getnameinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0xa1c): undefined reference
 to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0xa48): undefined reference
 to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x14ae): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x14e7): undefined referenc
e to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x162c): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x170f): undefined referenc
e to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x2713): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x281f): undefined referenc
e to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x2ffb): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x30bf): undefined referenc
e to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x32b3): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x3377): undefined referenc
e to `freeaddrinfo'
collect2: ld returned 1 exit status
make[1]: *** [geoiplookup.exe] Error 1
make[1]: Leaving directory `/home/Harp/GeoIP-1.4.6/apps'
make: *** [all-recursive] Error 1

当我只是尝试安装 GeoIP-Python 时,出现以下错误:

Harp@T500 ~/GeoIP-Python-1.2.4
$ python setup.py  install
running install
running build
running build_ext
building 'GeoIP' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -IInclude -Ic:\Python27\include -Ic:\Python27\PC /Tcpy_Geo
IP.c /Fobuild\temp.win32-2.7\Release\py_GeoIP.obj
py_GeoIP.c
py_GeoIP.c(31) : error C2059: syntax error : ';'
py_GeoIP.c(33) : error C2059: syntax error : '}'
py_GeoIP.c(37) : error C2065: 'GeoIP_GeoIPObject' : undeclared identifier
py_GeoIP.c(37) : error C2275: 'GeoIP' : illegal use of this type as an expressio
n
        c:\mingw\msys\1.0\home\harp\geoip-python-1.2.4\include\GeoIP.h(74) : see
 declaration of 'GeoIP'
py_GeoIP.c(38) : error C2143: syntax error : missing ';' before 'type'
py_GeoIP.c(40) : error C2065: 'flags' : undeclared identifier
...
...
py_GeoIP.c(275) : error C2065: 'GeoIP_GeoIPObject' : undeclared identifier
py_GeoIP.c(275) : error C2059: syntax error : ')'
py_GeoIP.c(275) : fatal error C1003: error count exceeds 100; stopping compilati
on
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.ex
e"' failed with exit status 2

我的目标是安装 GeoIP-Python。知道我该怎么做吗?或者有人可以解释这些错误的含义吗?

我尝试寻找预建选项,但没有找到。

I am trying to install GeoIP-Python-1.2.4 on Windows 7.
Before I can do that, I need to install GeoIP-1.4.6.
I am using README.MinGW instructions for installation. I used MinGW and got through ./configure. When I do 'make', I get following error:

*** Warning: This system can not link to static lib archive libGeoIP.la.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.
libtool: link: warning: undefined symbols not allowed in i686-pc-mingw32 shared
libraries
ar cru .libs/libGeoIPUpdate.a  GeoIPUpdate.o md5.o
ranlib .libs/libGeoIPUpdate.a
creating libGeoIPUpdate.la
(cd .libs && rm -f libGeoIPUpdate.la && cp -p ../libGeoIPUpdate.la libGeoIPUpdat
e.la)
make[1]: Leaving directory `/home/Harp/GeoIP-1.4.6/libGeoIP'
Making all in apps
make[1]: Entering directory `/home/Harp/GeoIP-1.4.6/apps'
gcc -DPACKAGE_NAME=\"GeoIP\" -DPACKAGE_TARNAME=\"GeoIP\" -DPACKAGE_VERSION=\"1.4
.6\" -DPACKAGE_STRING=\"GeoIP\ 1.4.6\" -DPACKAGE_BUGREPORT=\"[email protected]
\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -
DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE
_STDINT_H=1 -DHAVE_UNISTD_H=1 -D__EXTENSIONS__=1 -D_ALL_SOURCE=1 -D_GNU_SOURCE=1
 -D_POSIX_PTHREAD_SEMANTICS=1 -D_TANDEM_SOURCE=1 -DPACKAGE=\"GeoIP\" -DVERSION=\
"1.4.6\" -DLITTLE_ENDIAN_HOST=1 -DHAVE_STDINT_H=1 -DHAVE_ZLIB_H=1 -DHAVE_GETTIME
OFDAY=1 -DHAVE_VSNPRINTF=1 -DHAVE_VSPRINTF=1 -I. -I../libGeoIP -Wall -DSYSCONFDI
R=\"/usr/local/etc\" -Wall   -O3 -I/usr/local/include -c geoiplookup.c
/bin/sh ../libtool --tag=CC   --mode=link gcc  -O3 -I/usr/local/include  -L/usr/
local/lib -lwsock32 -o geoiplookup.exe geoiplookup.o ../libGeoIP/libGeoIP.la
mkdir .libs
gcc -O3 -I/usr/local/include -o geoiplookup.exe geoiplookup.o  -L/usr/local/lib
../libGeoIP/.libs/libGeoIP.a -lwsock32
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x8af): undefined reference
 to `getnameinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0xa1c): undefined reference
 to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0xa48): undefined reference
 to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x14ae): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x14e7): undefined referenc
e to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x162c): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x170f): undefined referenc
e to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x2713): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x281f): undefined referenc
e to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x2ffb): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x30bf): undefined referenc
e to `freeaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x32b3): undefined referenc
e to `getaddrinfo'
../libGeoIP/.libs/libGeoIP.a(GeoIP.o):GeoIP.c:(.text+0x3377): undefined referenc
e to `freeaddrinfo'
collect2: ld returned 1 exit status
make[1]: *** [geoiplookup.exe] Error 1
make[1]: Leaving directory `/home/Harp/GeoIP-1.4.6/apps'
make: *** [all-recursive] Error 1

When i simply try to install GeoIP-Python, I get following error:

Harp@T500 ~/GeoIP-Python-1.2.4
$ python setup.py  install
running install
running build
running build_ext
building 'GeoIP' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -IInclude -Ic:\Python27\include -Ic:\Python27\PC /Tcpy_Geo
IP.c /Fobuild\temp.win32-2.7\Release\py_GeoIP.obj
py_GeoIP.c
py_GeoIP.c(31) : error C2059: syntax error : ';'
py_GeoIP.c(33) : error C2059: syntax error : '}'
py_GeoIP.c(37) : error C2065: 'GeoIP_GeoIPObject' : undeclared identifier
py_GeoIP.c(37) : error C2275: 'GeoIP' : illegal use of this type as an expressio
n
        c:\mingw\msys\1.0\home\harp\geoip-python-1.2.4\include\GeoIP.h(74) : see
 declaration of 'GeoIP'
py_GeoIP.c(38) : error C2143: syntax error : missing ';' before 'type'
py_GeoIP.c(40) : error C2065: 'flags' : undeclared identifier
...
...
py_GeoIP.c(275) : error C2065: 'GeoIP_GeoIPObject' : undeclared identifier
py_GeoIP.c(275) : error C2059: syntax error : ')'
py_GeoIP.c(275) : fatal error C1003: error count exceeds 100; stopping compilati
on
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.ex
e"' failed with exit status 2

My objective is to install GeoIP-Python. Any idea how I can do it? or can someone explain what these errors mean?

I tried looking for pre-built option, but was not able to find any.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

极致的悲 2024-10-31 20:21:52

您可能想尝试

python setup.py build_ext -cmingw32

(或-cmingw,不记得了。)

这样它将尝试使用MinGW编译器(它默认为MSVC,正如您从命令行中看到的那样)

You may want to try

python setup.py build_ext -cmingw32

(or -cmingw, can't remember.)

This way it'll try to use the MinGW compiler (it defaults, as you can see from the command line, to MSVC)

明天过后 2024-10-31 20:21:52

更好的选择: pygeoip ,它是 MaxMind GeoIP 数据库的纯 python API,不要不再需要 C API

better choice: pygeoip , it's pure python API for MaxMind GeoIP databases, don't need C API anymore

奢望 2024-10-31 20:21:52

我在构建 GeoIP C 库时通过更改说明中给出的 LDFLAGS 解决了链接器错误。我没有链接winsock32,而是链接了ws2_32。 Make check 对我来说仍然失败,但仅在 2 个国家/地区代码按名称测试上失败。按地址测试的国家/地区代码完成得很好。

I got around the linker errors while building the GeoIP C library by altering the LDFLAGS they give in the instructions. Instead of linking winsock32, I linked ws2_32. Make check still fails for me, but only on 2 country code by name tests. The country code by address tests completed just fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文