# How to compile the julia code into c language?

**URL:** <https://discourse.julialang.org/t/how-to-compile-the-julia-code-into-c-language/76573>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 16, 2022, 5:19pm UTC](https://discourse.julialang.org/t/how-to-compile-the-julia-code-into-c-language/76573 "2022-02-16T17:19:29Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 17, 2022, 11:02pm UTC](https://discourse.julialang.org/t/how-to-compile-the-julia-code-into-c-language/76573/25 "2022-02-17T23:02:29Z")

</div>

In section 22.2 of the OpenModelica User Guide it describes how to call Python code by using the standard Python API (in `Python.h`) and linking `libpython`.

You can do exactly the same thing with `julia.h` and `libjulia`.

---

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [February 17, 2022, 11:18pm UTC](https://discourse.julialang.org/t/how-to-compile-the-julia-code-into-c-language/76573/26 "2022-02-17T23:18:03Z")

</div>

@stevengj Thank you very much!

I have looked at section 22.2 of the OpenModelica User Guide which looks helpful. However, I came a cross this part  
 ![Screenshot 2022-02-17 184503](https://global.discourse-cdn.com/julialang/original/3X/4/8/489e3c25fb675645ae1ee6cef1762a171dfa0f9f.png)

In which I dont know how to define the settings that are compatible for Julia instead of `python-config --cflags > pycflags"` and “python-config --ldflags \> pyldflags”) in the OMEdit of Openmodelia

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [February 18, 2022, 2:12am UTC](https://discourse.julialang.org/t/how-to-compile-the-julia-code-into-c-language/76573/27 "2022-02-18T02:12:08Z")

</div>

I got lost in the conversation. Did you try creating a shared library with PackageCompiler, and making your julia function callable via `Base.@ccallable` yet? You can then write some glue code in C that calls your julia function.

[https://docs.juliahub.com/PackageCompiler/MMV8C/1.2.1/devdocs/binaries\_part\_2.html#Interacting-with-Julia-through-libjulia.-1](https://docs.juliahub.com/PackageCompiler/MMV8C/1.2.1/devdocs/binaries_part_2.html#Interacting-with-Julia-through-libjulia.-1)

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [February 18, 2022, 7:19am UTC](https://discourse.julialang.org/t/how-to-compile-the-julia-code-into-c-language/76573/28 "2022-02-18T07:19:37Z")

</div>

I am going to ask a controversial question. How much time do you have invested in Modelica? Would you be able to find similar functions in Julia packages?  
If you can say what you are working on maybe some people here can suggest equivalents in Julia? For instance

> **[JuliaDynamics](https://juliadynamics.github.io/JuliaDynamics/)**
>
> Software For Dynamical Systems

---

<div class="post-metadata">

**Author:** ![wly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wly/32/49517_2.png) [@wly](https://discourse.julialang.org/u/wly)\
**Post date:** [June 18, 2023, 2:23am UTC](https://discourse.julialang.org/t/how-to-compile-the-julia-code-into-c-language/76573/29 "2023-06-18T02:23:35Z")

</div>

Maybe [converting\_to\_C in symbolics](https://symbolics.juliasymbolics.org/dev/tutorials/converting_to_C/) is suitable?

[Previous page](https://discourse.julialang.org/t/how-to-compile-the-julia-code-into-c-language/76573.md?page=1)
