Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run c++ program on heroku

Tags:

c++

heroku

I am trying to run a c++ program on Heroku, I've read this post: How to run an executable on Heroku from node, works locally however I didn't manage to make it work because the server doesn't have g++ on it (or gcc for that matter). I tried downloading g++ onto the server like so sudo apt-get install g++ however I don't have root permissions. Also I tried copying my copy of g++ to the server but my mac has a different architecture than the server so that didn't work either. Clearly this is possible seeing as that it has been solved in the question I linked above however I can't figure out how to do it. Any help is appreciated. Thanks.

like image 243
Mathew Avatar asked May 31 '18 03:05

Mathew


2 Answers

There are 2 ways you can do this.

Using Heroku's buildpack api, you can setup a buildpack which will compile your code when the app is being built.

There is even a few C buildpacks available: https://github.com/heroku/heroku-buildpack-c

You can also use Docker. Your Dockerfile would build the binary. You could run it locally, then push and release it to Heroku. See https://devcenter.heroku.com/articles/container-registry-and-runtime

like image 55
Damien MATHIEU Avatar answered Oct 16 '22 09:10

Damien MATHIEU


In case there is someone else out there trying to this, I got it to work by compiling it on a linux machine then uploaded the executable to Heroku. So assuming one has access to a linux machine with g++ on it, this should be possible.

like image 34
Mathew Avatar answered Oct 16 '22 10:10

Mathew