# Passing a Julia struct to a already compiled cpp program

**URL:** <https://discourse.julialang.org/t/passing-a-julia-struct-to-a-already-compiled-cpp-program/124731>\
**Category:** General Usage\
**Tags:** question, cxx, memory-allocation, struct\
**Created:** [January 13, 2025, 3:27pm UTC](https://discourse.julialang.org/t/passing-a-julia-struct-to-a-already-compiled-cpp-program/124731 "2025-01-13T15:27:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheBreadFarmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thebreadfarmer/32/214664_2.png) [@TheBreadFarmer](https://discourse.julialang.org/u/TheBreadFarmer)\
**Post date:** [January 13, 2025, 3:27pm UTC](https://discourse.julialang.org/t/passing-a-julia-struct-to-a-already-compiled-cpp-program/124731/1 "2025-01-13T15:27:56Z")

</div>

I am writing a program in Julia that reads data from a file into memory. I’d like to take that data and somehow pass it to a c++ program which will make use of OpenGL to draw that data to the screen.

I am making use of Visual Studio 22 for writing my C++ program. For OpenGL I am using GLFW and GLEW libraries.

Does anyone have any recommendations on how to accomplish this?

I am happy to answer any clarifying questions!

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [January 13, 2025, 6:01pm UTC](https://discourse.julialang.org/t/passing-a-julia-struct-to-a-already-compiled-cpp-program/124731/2 "2025-01-13T18:01:10Z")

</div>

> [@TheBreadFarmer](#):
>
> I am making use of Visual Studio 22 for writing my C++ program.

If it’s your own C++ code (or building it from source) the best solution (that I know) is to create C wrapper functions with

```julia
extern "C" {
   int foo(...);
}

```

that you can latter call with the `ccall` mechanism.
