Skip to content

Instantly share code, notes, and snippets.

@madis
Last active December 23, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madis/6634472 to your computer and use it in GitHub Desktop.
Save madis/6634472 to your computer and use it in GitHub Desktop.
Compiling geoip-c for ruby 2.0.0 vs 1.9.3 mkmf error
// Compile with:
// export RUBY_DIR=$HOME/.rvm/rubies/ruby-1.9.3-p448
// gcc-4.6 -o for_1.9.3 -I$RUBY_DIR/include/ruby-1.9.1/x86_64-darwin12.4.1 -I$RUBY_DIR/include/ruby-1.9.1/ruby/backward -I$RUBY_DIR/include/ruby-1.9.1 -Iext/geoip -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fno-common -pipe for_1.9.3.c -L. -L$RUBY_DIR/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -liconv -lruby.1.9.1 -lGeoIP -liconv -lpthread -ldl -lobjc
#include "ruby.h"
int t() { GeoIP_record_by_ipnum(); return 0; }
int main(int argc, char **argv)
{
if (argc > 1000000) {
printf("%p", &t);
}
return 0;
}
// Compile with
// export RUBY_DIR=$HOME/.rvm/rubies/ruby-2.0.0-p247
// /usr/bin/clang -o for_2.0.0 -I$RUBY_DIR/include/ruby-2.0.0/x86_64-darwin12.3.0 -I$RUBY_DIR/include/ruby-2.0.0/ruby/backward -I$RUBY_DIR/include/ruby-2.0.0 -Iext/geoip -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -I/Users/mpapis/.sm/pkg/active/include -fPIC -pipe for_2.0.0.c -L. -L$RUBY_DIR/lib -L. -Z -L/Users/mpapis/.sm/pkg/active/lib -L/usr/lib -fPIC -Bstatic -fstack-protector -arch x86_64 -liconv -lruby-static -lGeoIP -liconv -lpthread -ldl -lobjc
#include "ruby.h"
extern int t(void);
int t(void) { void ((*volatile p)()); p = (void ((*)()))GeoIP_record_by_ipnum; return 0; }
int main(int argc, char **argv)
{
if (argc > 1000000) {
printf("%p", &t);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment