InitError: could not load library "...libcxxwrap_julia_stl.dll" on windows

I successfully build libcxxwrap_julia from source on Windows using

cmake -DJulia_EXECUTABLE="home/AppData/Local/Programs/Julia-1.6.3/bin/julia" .. -G "Visual Studio 16"
cmake --build . --config=Release

and have added an Overrides.toml file in the .julia/arctifacts folder

[3eaa8342-bff7-56a5-9981-c04077f7cee7]
libcxxwrap_julia = "C:/Users/rrhie/Documents/cpp-test/libcxxwrap-julia/build"

When I open julia in the REPL, add and use CxxWrap I get the following error

julia> using CxxWrap
ERROR: InitError: could not load library 
"C:\Users\rrhie\.julia\artifacts\41b86dcf7a6b239850cbbc378d7eaa5a87d7e4f3\bin\libcxxwrap_julia_stl.dll"
The specified procedure could not be found.
Stacktrace: ...

It seems like CxxWrap is not using my locally compiled version of libcxxwrap_julia.

What am I doing wrong here?

1 Like

I just got it working. Apparently the Overrides.toml file was not correct, although I followed the instructions on libcxxwrap-julia

The contents of Overrides.toml that work are:

41b86dcf7a6b239850cbbc378d7eaa5a87d7e4f3 = "C:/Users/rrhie/Documents/cpp-test/libcxxwrap-julia/build"

So I used the content hash directly.

I will open an issue on libcxxwrap-julia
to adapt the installation instructions in their README.

1 Like

Hi @hiemstar , Thank you for the above it is helpful. I had the same error message that you have.
Changing the contents of Overrides.toml seemed to make it work however I got another error message after installing CxxWrap:

(@v1.7) pkg> add CxxWrap
Updating registry at `C\Users\gitboy\.julia\registries\General.toml`
Resolving package versions...
Downloaded artifact: libcxxwrap_julia
Downloaded artifact: libcxxwrap_julia
Updating `C\Users\gitboy\.julia\environments\1.7\Project.toml`
[1f15a43c] + CxxWrap v0.12.0
Updating `C\Users\gitboy\.julia\environments\1.7\Manifest.toml`
[1f15a43c] + CxxWrap v0.12.0
[1914dd2f] + MacroTools v0.5.9
[3eaa8342] +libcxxwrap_julia_jll v0.9.0+0
Info packages marked with not downloaded, use `instantiate` to download
Downloaded artifact: libcxxwrap_julia
Downloaded artifact: libcxxwrap_julia

julia> using CxxWrap
ERROR: InitError: Artifact "libccxwrap_julia" was not installed correctly. Try `using Pkg; Pkg.instantiate()` to re-install all missing resources.
Stacktrace:
[1] error(s::String)
@Base .\error.jl:33
[2] _artifact_str ...etc

julia> using Pkg; Pkg.instantiate()
Downloaded artifact: libcxxwrap_julia
Downloaded artifact: libcxxwrap_julia

julia> using CxxWrap
Error: InitError: could not load library ""
The parameter ia incorrect.
Stacktrace:
[1] libcxxwrapversion()
@ CxxWrap.CxxWrapCore C:\Users\gitboy\.julia\packages\CxxWrap\ptbgM\src\CxxWrap.jl:33
during initialization of module CxxWrapCore

julia>

Any idea how I can solve this? Thank you
Fyi similar issue here: Ccall c++ sort vector of String - #33 by barche

Are you building libcxxwrap-julia from source? On windows you cannot use the one provided by CxxWrap.

Yes I am building it from sources.
Would you be able to give the exact list of windows command you run from the very beginning (including the git clone …etc) because I had to change your first command from:

cmake -DJulia_EXECUTABLE="home/AppData/Local/Programs/Julia-1.6.3/bin/julia" .. -G "Visual Studio 16"

To

cmake -G "Visual Studio 16"  -DJulia_EXECUTABLE="D:/Julia-1.7.1/bin/julia" . 

In order to make it work.
I also had to change the hash in the toml file because mine is different. Thank you