# c/c++ code generation

**URL:** <https://community.wolfram.com/t/c-c-code-generation/20448>\
**Category:** Questions\
**Tags:** data-science, software-development, mathematica, external-interfaces, machine-learning\
**Created:** [July 26, 2022, 9:01pm UTC](https://community.wolfram.com/t/c-c-code-generation/20448 "2022-07-26T21:01:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![josephmbayi75](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@josephmbayi75](https://community.wolfram.com/u/josephmbayi75)\
**Post date:** [July 26, 2022, 9:01pm UTC](https://community.wolfram.com/t/c-c-code-generation/20448/1 "2022-07-26T21:01:19Z")

</div>

Hello, can I use Mathematica to generate c/c++ code that I can Include in an external program that can run independently of Mathematica, for example after developing a control algorithm or a machine learning model using wolfram Mathematica can I generate c/c++ code/ library that I can include in a project?

---

<div class="post-metadata">

**Author:** ![me14](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/me14/32/32699_2.png) [@me14](https://community.wolfram.com/u/me14)\
**Post date:** [August 3, 2022, 10:40pm UTC](https://community.wolfram.com/t/c-c-code-generation/20448/2 "2022-08-03T22:40:39Z")

</div>

Hi Joseph, yes, the Wolfram Language can do those, but not in an holistic way.  
For the C/C++ code generation you have to create a compiled function (look up the Wolfram Compiler on Google). From there you’ve got two paths: 1. Generate C code using the [CCodeGenerator](https://reference.wolfram.com/language/CCodeGenerator/guide/CCodeGenerator.html) or 2. directly leverage the Compiler to get extremely fast and optimized compiled code, that you can then call from your stand-alone programs or run that at a very high speed within your Notebook. For the Neural Network exporting, it’s extremely simple: You can just use [Export](https://reference.wolfram.com/language/ref/Export.html) to save your model in the [MXNet](https://reference.wolfram.com/language/ref/format/MXNet.html) format or the [ONNX](https://www.wolfram.com/broadcast/video.php?c=104&disp=list&p=4&v=3563) one (adviced).

Last thing that I wanted to add, is that you can use the Wolfram Language without the Mathematica front-end, exactly like you do with your Python or Perl programs, and if you want to integrate your Wolfram code with other programs, there are [other ways](https://www.wolfram.com/wstp/), that are way easier than having to deal with code compilation (not the totality of the Wolfram Language can be compiled, for obvious reasons).
