Compiling C++ file for usage in Julia

Hi, and welcome to the Julia community!

I can confirm that your code and the one from the post you referred to also does not work for me on Windows. The CMake example from the CxxWrap.jl github page 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:

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> using CxxWrap

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

julia> greet()
"Hello World!"

works for me.

1 Like