1

I have an intermediate level with Ruby on Rails and have always deployed my web application through Heroku. I would like to develop a web application in Rails that would be able to interact with the following API https://musicbrainz.org/doc/libmusicbrainz. The libraries seem to be in C/C++. How do I bridge the gap between my Rails application in Ruby and a library which will provide me with C/C++ functions/files?

In the same spirit, if I develop a C++ application, compile the code and create the desired executable. How do I turn this program into a web application? Am I supposed to load the executable on Heroku and somehow call the program through Rails? Am I supposed to re-write the program in Ruby?

What is the general rule when we come to use libraries/programs which are not written in the same language than the core server-side language (Ruby in my case)?

I had a look at the following post How can I call C++ functions from within ruby but a more detailed answer with a clear path to on what steps I should follow would be helpful. Thank you.

Community
  • 1
  • 1
Bastien
  • 596
  • 1
  • 11
  • 30

1 Answers1

2

What is the general rule when we come to use libraries/programs which are not written in the same language than the core server-side language (Ruby in my case)? The best solution in your case seems to be create a Ruby extension in C. The C++ code will interact with the API https://musicbrainz.org/doc/libmusicbrainz and send the data to your Ruby module.

For further reference see this http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html

mhaseeb
  • 1,739
  • 2
  • 12
  • 24