From 28246b3f650d1ed8433e88108a0771a3f6f38920 Mon Sep 17 00:00:00 2001 From: CHENQ Date: Sun, 9 Oct 2016 17:55:15 +0800 Subject: [PATCH 1/2] change to support MSYS (windows) --- README.md | 28 ++++++++++++++++++++++++++++ geoip.go | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 59ebaa1..627e2a7 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,34 @@ Country](http://www.maxmind.com/app/geoip_country) database or you can country := gi6.GetCountry_v6("2607:f238:2::5") fmt.Println(country) +## build + +###windows use MSYS/MSYS2 + +1. build libGeoIP (geoip-api-c) + + see https://github.com/maxmind/geoip-api-c/releases page + download latest version + tar xvf ... + + ./configure --disable-shared --disable-dependency-tracking --disable-data-files CFLAGS=-D_WIN32_WINNT=0x0501 + + `CFLAGS=-D_WIN32_WINNT=0x0501` enable link winsock2 `ws32` + without this will show build error : + + Undefined reference to getaddrinfo + ... + + +2. build(install) geoip static + + CGO_ENABLED=1 GOOS=windows CGO_CFLAGS=-I/usr/local/include CGO_LDFLAGS='-L/usr/local/lib -lGeoIP -lwsock32 -lws2_32' go install -x --ldflags '-extldflags "-static"' github.com/chennqqi/geoip + + + github.com/chennqqi/geoip or source repo github.com/abh/geoip + + my MSYS don't contain `pkg-config`, so i comment in geoip.go + ## Contact diff --git a/geoip.go b/geoip.go index 4d264fd..1abe225 100644 --- a/geoip.go +++ b/geoip.go @@ -2,7 +2,7 @@ package geoip /* -#cgo pkg-config: geoip +//#cgo pkg-config: geoip #include #include #include From d37e06385a0545b83023c9a2b41b2054a5216929 Mon Sep 17 00:00:00 2001 From: chennqqi Date: Sun, 9 Oct 2016 17:59:03 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 627e2a7..6a67326 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Country](http://www.maxmind.com/app/geoip_country) database or you can github.com/chennqqi/geoip or source repo github.com/abh/geoip - my MSYS don't contain `pkg-config`, so i comment in geoip.go + my MSYS don't contain `pkg-config`, so i comment it in geoip.go ## Contact