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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With