# Compiling Julia to C/C++ or small executable file

**URL:** <https://discourse.julialang.org/t/compiling-julia-to-c-c-or-small-executable-file/86949>\
**Category:** General Usage\
**Tags:** package-compiler\
**Created:** [September 8, 2022, 3:46pm UTC](https://discourse.julialang.org/t/compiling-julia-to-c-c-or-small-executable-file/86949 "2022-09-08T15:46:29Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [September 8, 2022, 4:20pm UTC](https://discourse.julialang.org/t/compiling-julia-to-c-c-or-small-executable-file/86949/3 "2022-09-08T16:20:45Z")

</div>

You can make small binaries (limited subset of Julia):

> [@Successful Static Compilation of Julia Code for use in Production](https://discourse.julialang.org/t/successful-static-compilation-of-julia-code-for-use-in-production/79318):
>
> The [StaticCompiler](https://github.com/tshort/StaticCompiler.jl) package was recently registered. This post records a successful experiment to statically compile a piece of Julia code into a small .so library on Linux, which is then loaded from Python and used in training of a deep learning model. TLDR Static compilation to a stand-alone library does work on Linux but has rather significant restrictions on the functionality available. It is mostly useful for core computational routines. Roughly speaking, if it could be implemented in plai…

> ### Calling the Library from Python

That’s just an example, you can call from C or C++ too.

There’s already the outdated/unmaintained Intel’s Julia2C (for a limited subset of Julia; to C++ possible too):

> [@Status of and need for ParallelAccelerator](https://discourse.julialang.org/t/status-of-and-need-for-parallelaccelerator/19277):
>
> I just notice it’s one of the packages that hasn’t been upgraded, still stuck on 0.6. I’m just thinking is this more of a testament of there no longer being a need with Julia 1.0+ much faster with or without say thread handing? Other abandoned IntelLabs projects are Julia2C and HPAT.jl. HPAT was one of my favorites to point to. It just seemed like an awesome Julia-only package, 100x faster than mainstream competitors. It still may be that, while it didn’t require being made in Julia with Inte…

If you want to call Julia from C++, with all Julia features possible including eval, then there’s the seemingly awesome (well documented) Jluna project for that. Similar project to call from Rust. And from C, just the embedding API, these build on.

> **[GitHub - Clemapfel/jluna: Julia Wrapper for C++ with Focus on Safety,...](https://github.com/Clemapfel/jluna)**
>
> Julia Wrapper for C++ with Focus on Safety, Elegance, and Ease of Use

You can’t have small binaries with all Julia features, at least if you include eval (that you may want to avoid anyway), since with it Julia is strictly more powerful than C or C++; then you need the backend of the compiler, LLVM dependency. But you can drop that (and some other dependencies, for smaller binaries if not needed.

---

_[View the full topic](https://discourse.julialang.org/t/compiling-julia-to-c-c-or-small-executable-file/86949)._
