desuwa / hive_geoip2 Goto Github PK
View Code? Open in Web Editor NEWlibmaxminddb GeoIP2 Ruby bindings
libmaxminddb GeoIP2 Ruby bindings
https://www.redhat.com/en/blog/new-warnings-and-errors-clang-16
Warning incompatible-function-pointer-types
has been upgraded to an error. As a result, the gem native extension does not build.
$ clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gcc --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ ruby --version
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [arm64-darwin23]
gem install hive_geoip2 -v 0.1.2 -- --with-maxminddb-include=$(brew --prefix libmaxminddb)/include/ --with-maxminddb-lib=$(brew --prefix libmaxminddb)/lib
fails with
compiling hive_geoip2.c
hive_geoip2.c:102:18: warning: passing 'const uint8_t *' (aka 'const unsigned char *') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
*ret_obj = rb_enc_str_new(
^~~~~~~~~~~~~~~
~/.asdf/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/internal/encoding/string.h:335:24: note: expanded from macro 'rb_enc_str_new'
rb_enc_str_new) ((str), (len), (enc)))
^~~~~
hive_geoip2.c:160:22: warning: initializing 'const uint8_t *' (aka 'const unsigned char *') with an expression of type 'const char[17]' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
const uint8_t *hex = "0123456789abcdef";
^ ~~~~~~~~~~~~~~~~~~
hive_geoip2.c:186:22: warning: initializing 'const uint8_t *' (aka 'const unsigned char *') with an expression of type 'const char[17]' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
const uint8_t *hex = "0123456789abcdef";
^ ~~~~~~~~~~~~~~~~~~
hive_geoip2.c:213:31: warning: passing 'uint8_t[size * 2 + 1]' (aka 'unsigned char[size * 2 + 1]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
*ret_obj = rb_cstr2inum(buf, 16);
^~~
~/.asdf/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/internal/intern/bignum.h:171:32: note: passing argument to parameter 'str' here
VALUE rb_cstr2inum(const char *str, int base);
^
hive_geoip2.c:169:21: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
for (i = size - 1; i >= 0; i--) {
~ ~~~~~^~~
hive_geoip2.c:205:21: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
for (i = size - 1; i >= 0; i--) {
~ ~~~~~^~~
hive_geoip2.c:310:16: error: incompatible function pointer types passing 'void (VALUE)' (aka 'void (unsigned long)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
rb_protect(guard_parse_data_list, (VALUE)&args, &exception);
^~~~~~~~~~~~~~~~~~~~~
~/.asdf/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/internal/intern/proc.h:349:26: note: passing argument to parameter 'func' here
VALUE rb_protect(VALUE (*func)(VALUE args), VALUE args, int *state);
^
6 warnings and 1 error generated.
make: *** [hive_geoip2.o] Error 1
However, downgrading the error to warning bypasses the issue:
$ gem install hive_geoip2 -v 0.1.2 -- --with-maxminddb-include=$(brew --prefix libmaxminddb)/include/ --with-maxminddb-lib=$(brew --prefix libmaxminddb)/lib --with-cflags="-Wno-error=incompatible-function-pointer-types"
Building native extensions with: '--with-maxminddb-include=/opt/homebrew/opt/libmaxminddb/include/ --with-maxminddb-lib=/opt/homebrew/opt/libmaxminddb/lib --with-cflags=-Wno-error=incompatible-function-pointer-types'
This could take a while...
Successfully installed hive_geoip2-0.1.2
1 gem installed
Hello! I'm trying to set this up on a heroku. I'm compiling libmaxmind, and then I'm installing gem with --with-maxminddb-dir
.
After the second run I start getting this error (bundler no longer installs the gem, says Using hive_geoip2 0.1.2
LoadError: libmaxminddb.so.0: cannot open shared object file: No such file or directory -
Bundle install command I'm using is bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
And succeeds both times. (First time installs all dependecies, second time uses all installed dependencies).
The problem comes when a command is run on the app. But I'm not sure if this is a problem with this gem? The gem compiles again in the same place. Do you have any advice of where to look at?
Thanks!
Hi there.
I get the following output when I try to install the gem on my Mac OS X Yosemite system:
Building native extensions. This could take a while...
ERROR: Error installing hive_geoip2:
ERROR: Failed to build gem native extension.
/Users/jamessmith/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for maxminddb.h... yes
checking for main() in -lmaxminddb... yes
creating Makefile
make "DESTDIR="
compiling hive_geoip2.c
couldn't understand kern.osversion `14.0.0'
In file included from hive_geoip2.c:6:
/usr/local/include/maxminddb.h:57: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘mmdb_uint128_t’
/usr/local/include/maxminddb.h:87: error: expected specifier-qualifier-list before ‘mmdb_uint128_t’
hive_geoip2.c: In function ‘parse_data_list’:
hive_geoip2.c:106: warning: pointer targets in passing argument 1 of ‘rb_enc_str_new’ differ in signedness
hive_geoip2.c:124: error: ‘MMDB_entry_data_s’ has no member named ‘float_value’
hive_geoip2.c:151: error: ‘MMDB_entry_data_s’ has no member named ‘boolean’
hive_geoip2.c:160: warning: pointer targets in initialization differ in signedness
hive_geoip2.c:169: warning: implicit conversion shortens 64-bit value into a 32-bit value
hive_geoip2.c:186: warning: pointer targets in initialization differ in signedness
hive_geoip2.c:198: error: ‘mmdb_uint128_t’ undeclared (first use in this function)
hive_geoip2.c:198: error: (Each undeclared identifier is reported only once
hive_geoip2.c:198: error: for each function it appears in.)
hive_geoip2.c:200: error: ‘MMDB_entry_data_s’ has no member named ‘uint128’
hive_geoip2.c:205: warning: implicit conversion shortens 64-bit value into a 32-bit value
hive_geoip2.c:213: warning: pointer targets in passing argument 1 of ‘rb_cstr2inum’ differ in signedness
hive_geoip2.c: In function ‘mmdb_lookup’:
hive_geoip2.c:302: warning: ISO C90 forbids mixed declarations and code
hive_geoip2.c:310: warning: passing argument 1 of ‘rb_protect’ from incompatible pointer type
hive_geoip2.c: In function ‘rb_hive_geo_lookup’:
hive_geoip2.c:332: warning: ISO C90 forbids mixed declarations and code
hive_geoip2.c: In function ‘rb_hive_geo_lookup2’:
hive_geoip2.c:349: warning: ISO C90 forbids mixed declarations and code
hive_geoip2.c: In function ‘rb_hive_geo_init’:
hive_geoip2.c:396: warning: ISO C90 forbids mixed declarations and code
make: *** [hive_geoip2.o] Error 1
Gem files will remain installed in /Users/jamessmith/.rvm/gems/ruby-2.0.0-p247/gems/hive_geoip2-0.1.2 for inspection.
Results logged to /Users/jamessmith/.rvm/gems/ruby-2.0.0-p247/gems/hive_geoip2-0.1.2/ext/hive_geoip2/gem_make.out
Any thoughts on what might be causing this error?
Thanks,
James.
Hi there.
I upgraded to ruby 2.3.0
Installed bundler and installed my gemset from my rails app
hive_geoip2 fails because it cannot find maxminddb.h
It's looking inside /Users/me/.rvm/gems/ruby-2.3.0/gems/hive_geoip2-0.1.2/ext/hive_geoip2
/Users/me/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160120-32274-1551slx.rb extconf.rb
which is essentially /Users/me/.rvm/gems/ruby-2.3.0/gems/hive_geoip2-0.1.2/ext/hive_geoip2
I already used brew to install libmaxminddb
When I search for maxminddb.h with find /usr/local/include /usr/include -name maxminddb.h, I get:
/usr/local/include/maxminddb.h
find: /usr/include: No such file or directory
So it's inside my /usr/local/include
How do I resolve this issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.