1

I am trying to quickly calculate the hamming distance between two 64 bit integers in Ruby. I quickly discovered that even with Ruby's optimized string functions etc. it wouldn't be enough, so I turned to C extensions. For comparison, Pure Ruby benchmarked at about 350,000 comparisons per second and C extensions benchmarked at around 4,000,000.

I used the implementation here and compiled it on my computer where it worked fine. The problem I have is using it on Heroku. I tried ruby extconf.rb make to create the makefile, which worked, and then make to compile it which failed with make: gcc: Command not found. It doesn't matter to me if I do this on deploy or not, but I don't know how to run code automatically at deploy. This has vexed me - if anyone could help it would be much appreciated.

computergorl
  • 133
  • 1
  • 8
  • The usual way to do this would be to create a Gem containing the C extension, which would then be compiled when it is installed during deployment. – matt Jul 20 '17 at 02:42

1 Answers1

3

You can use Heroku Buildpacks to solve this https://blog.heroku.com/buildpacks

I did some work with the linguist gem which required C extensions to work and solved it by using the correct buildpack.

You can either use a prebuilt buildpack or build your own

Eric Himmelreich
  • 407
  • 4
  • 13
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/16764489) – Donald Duck Jul 19 '17 at 23:39
  • I edited the comment to include more instructions in case the link changes – Eric Himmelreich Jul 19 '17 at 23:55