# Compiling C++ file for usage in Julia

**URL:** <https://discourse.julialang.org/t/compiling-c-file-for-usage-in-julia/121693>\
**Category:** General Usage\
**Created:** [October 24, 2024, 11:51am UTC](https://discourse.julialang.org/t/compiling-c-file-for-usage-in-julia/121693 "2024-10-24T11:51:23Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [October 24, 2024, 7:48pm UTC](https://discourse.julialang.org/t/compiling-c-file-for-usage-in-julia/121693/8 "2024-10-24T19:48:36Z")

</div>

Hi, and welcome to the Julia community!

I can confirm that your code and the one from the [post you referred to](https://discourse.julialang.org/t/can-someone-provide-a-simple-example-of-using-cxxwrap/115908/6) also does not work for me on Windows. The CMake example from the CxxWrap.jl [github page](https://github.com/JuliaInterop/libcxxwrap-julia/tree/main/testlib-builder/src/testlib) did work without any issues though.

I’m certainly no expert on these matters, but it seems on Windows you need to explicitly link to the binaries:

```bash
g++ -shared -fPIC -o greetings.so -I (...)\.julia\artifacts\6907059f4600a8fd77020c49e83de7dbbea3a28c\include -I (...)\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\include\julia -L (...)\.julia\artifacts\6907059f4600a8fd77020c49e83de7dbbea3a28c\bin -L (...)\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\bin .\greetings.cpp -lcxxwrap_julia -ljulia

```

```julia-repl
julia> using CxxWrap

julia> @wrapmodule(() -> "greetings.so") # Assuming you started Julia in the same folder

julia> greet()
"Hello World!"

```

works for me.

---

_[View the full topic](https://discourse.julialang.org/t/compiling-c-file-for-usage-in-julia/121693)._
