maxmind / geoip-api-c

DEPRECATED GeoIP Legacy C API
Other
371 stars 129 forks source link

How to get libgeoip's version number #99

Closed sgeto closed 5 years ago

sgeto commented 6 years ago

Quick question: Any suggestions on how to determine libgeoip's version at configuration time? Preferably without the use of the pkg-config and without having to compile and run a dummy app?

Would you say this is this safe/reliable:

strings /path/to/libGeoIP.a | egrep -m 1 -o "([0-9]{1,}\.)+[0-9]{1,}"

thanks

horgh commented 6 years ago

I don't think there is a great way to do this if you're working with libGeoIP.a alone.

The command you show does seem to work, but I don't think it can be counted on.

The most reliable way would be to call GeoIP_lib_version(). You could perhaps do something like an autoconf run test that compiles and runs a small program. Although it sounds like this is something you'd like to avoid.

In theory we might be able to do something such as add a symbol that we could look up via objdump or something, but as far as I can tell there is nothing available currently.

You could check the version associated with the .so as we use libtool to assign a version. e.g. building the library produces libGeoIP.so.1.6.12 today.

pprindeville commented 6 years ago

You could perhaps do something like an autoconf run test that compiles and runs a small program. Although it sounds like this is something you'd like to avoid.

For those of us who do a lot of cross-compilation, this is unfriendly...

sgeto commented 6 years ago

Unfortunately not even checking the .so suffix is very cross-platform as windows libs don't have the lib version appended. Okay, how about checking whether a symbol/function exists? I'm not too fit with geoip's changelog. What function was introduced last? And what with version 1.5 ect?

horgh commented 6 years ago

Looking for particular symbols may be a better heuristic than using strings, but it I don't think there is any guarantee it will be future proof. However if you are intent on it, you could try searching for "function" in the commit log.

oschwald commented 5 years ago

Closing as future development is focused on libmaxminddb.