Ironholds / rgeolocate

Generalised IP geolocation through R
https://cran.r-project.org/web/packages/rgeolocate/index.html
Other
66 stars 22 forks source link

ip2location Windows support #34

Closed Ironholds closed 7 years ago

Ironholds commented 8 years ago

Building on Windows gets:

`* installing source package 'rgeolocate' ... \ libs

*\ arch - i386 d:/Compiler/gcc-4.9.3/mingw_32/bin/gcc -I"D:/RCompile/recent/R/include" -DNDEBUG -I"d:\RCompile\CRANpkg\lib\3.4/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -pedantic -O3 -Wall -std=gnu99 -mtune=core2 -c IP2Loc_DBInterface.c -o IP2Loc_DBInterface.o IP2Loc_DBInterface.c: In function 'IP2Location_DB_close': IP2Loc_DBInterface.c:214:17: warning: unused variable 'statbuf' [-Wunused-variable] struct stat statbuf; ^ d:/Compiler/gcc-4.9.3/mingw_32/bin/gcc -I"D:/RCompile/recent/R/include" -DNDEBUG -I"d:\RCompile\CRANpkg\lib\3.4/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -pedantic -O3 -Wall -std=gnu99 -mtune=core2 -c IP2Location.c -o IP2Location.o IP2Location.c: In function 'IP2Location_parse_addr': IP2Location.c:198:9: warning: implicit declaration of function 'inet_pton' [-Wimplicit-function-declaration] inet_pton(AF_INET6, addr, &parsed.ipv6); ^ d:/Compiler/gcc-4.9.3/mingw_32/bin/g++ -I"D:/RCompile/recent/R/include" -DNDEBUG -I"d:\RCompile\CRANpkg\lib\3.4/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -w -pedantic -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o d:/Compiler/gcc-4.9.3/mingw_32/bin/g++ -I"D:/RCompile/recent/R/include" -DNDEBUG -I"d:\RCompile\CRANpkg\lib\3.4/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -w -pedantic -O2 -Wall -mtune=core2 -c ip2.cpp -o ip2.o d:/Compiler/gcc-4.9.3/mingw_32/bin/g++ -I"D:/RCompile/recent/R/include" -DNDEBUG -I"d:\RCompile\CRANpkg\lib\3.4/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -w -pedantic -O2 -Wall -mtune=core2 -c ip_to_df.cpp -o ip_to_df.o d:/Compiler/gcc-4.9.3/mingw_32/bin/g++ -I"D:/RCompile/recent/R/include" -DNDEBUG -I"d:\RCompile\CRANpkg\lib\3.4/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -w -pedantic -O2 -Wall -mtune=core2 -c maxmind.cpp -o maxmind.o d:/Compiler/gcc-4.9.3/mingw_32/bin/gcc -I"D:/RCompile/recent/R/include" -DNDEBUG -I"d:\RCompile\CRANpkg\lib\3.4/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -pedantic -O3 -Wall -std=gnu99 -mtune=core2 -c maxminddb.c -o maxminddb.o d:/Compiler/gcc-4.9.3/mingw_32/bin/g++ -I"D:/RCompile/recent/R/include" -DNDEBUG -I"d:\RCompile\CRANpkg\lib\3.4/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -w -pedantic -O2 -Wall -mtune=core2 -c rgeolocate.cpp -o rgeolocate.o d:/Compiler/gcc-4.9.3/mingw_32/bin/g++ -shared -s -static-libgcc -o rgeolocate.dll tmp.def IP2Loc_DBInterface.o IP2Location.o RcppExports.o ip2.o ip_to_df.o maxmind.o maxminddb.o rgeolocate.o -lws2_32 -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LD:/RCompile/recent/R/bin/i386 -lR IP2Location.o:IP2Location.c:(.text+0x741): undefined reference to inet_pton' IP2Location.o:IP2Location.c:(.text+0x764): undefined reference toinet_pton' IP2Location.o:IP2Location.c:(.text+0x1047): undefined reference to `inet_pton' collect2.exe: error: ld returned 1 exit status no DLL was created ERROR: compilation failed for package 'rgeolocate'

Ironholds commented 8 years ago

@hrbrmstr you volunteered to take windoze for a spin, I think? Problems seem to be twofold:

  1. Recognising inet_pton;
  2. Getting information out of the stat struct defined in sys/stat.h without declaring it - I dunno if we want to just have a fake use for it, or what.
wrathematics commented 8 years ago

inet_pton is nix only. If you don't care about XP, it's not too hard to write a shim to fix shit; if you do it's much harder. See https://github.com/wrathematics/getip/blob/master/src/validate.c

hrbrmstr commented 8 years ago

I personally don't want to encourage use of XP and I think I also have a shim somewhere for it (but can steal that one as well). That reminds me that I need to get back to that ip pkg we bantered abt @wrathematics.

wrathematics commented 8 years ago

A lot of people still use it. I've never looked into CRAN's position, but I'm guessing they don't support it anymore, so it's really up to you is my guess. That file I linked is for ipv4 addresses on xp or later. If you assume at least vista, you need to give InetPton an inet_pton interface.

hrbrmstr commented 8 years ago

as a security dude, encouraging use of XP in any capacity is really hard to do ;-) I'll dig up what I've done before (it's pretty much what you indicated).

Ironholds commented 8 years ago

Aye; thought we'd (and by that I mean you and your brilliance) got around it in the max mind chunk already..

On Thursday, 20 October 2016, Drew Schmidt notifications@github.com wrote:

inet_pton is nix only. If you don't care about XP, it's not too hard to write a shim to fix shit; if you do it's much harder. See https://github.com/wrathematics/getip/blob/master/src/validate.c

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Ironholds/rgeolocate/issues/34#issuecomment-255163996, or mute the thread https://github.com/notifications/unsubscribe-auth/ACXz3vWQVA5F8V9ATWhPY60T10lBdQwOks5q15zRgaJpZM4KcWjo .

Ironholds commented 7 years ago

Any thoughts/luck on this'n?

hrbrmstr commented 7 years ago

https://github.com/hrbrmstr/iptools/blob/master/src/asio_bindings.cpp#L20-L159

Ironholds commented 7 years ago

yooou ROCK