# Cygwin mishap with Julia 1.9.0-alpha1 / Plots (dlopen cant open libcairo-2.dll

**URL:** <https://discourse.julialang.org/t/cygwin-mishap-with-julia-1-9-0-alpha1-plots-dlopen-cant-open-libcairo-2-dll/91179>\
**Category:** General Usage\
**Created:** [December 3, 2022, 1:45pm UTC](https://discourse.julialang.org/t/cygwin-mishap-with-julia-1-9-0-alpha1-plots-dlopen-cant-open-libcairo-2-dll/91179 "2022-12-03T13:45:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)\
**Post date:** [December 3, 2022, 1:45pm UTC](https://discourse.julialang.org/t/cygwin-mishap-with-julia-1-9-0-alpha1-plots-dlopen-cant-open-libcairo-2-dll/91179/1 "2022-12-03T13:45:48Z")

</div>

I have downloaded julia-1.9.0-alpha1, and in REPL (Terminal) it works OK.`

However, when I try to use it with Plots under Cygwin, Plots does not inits :

```julia
davidj@vivojdw ~$ julia19
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.9.0-alpha1 (2022-11-15)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

julia> @time using Plots
ERROR: InitError: could not load library "C:\Users\davidj\.julia\artifacts\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\bin\libcairo-2.dll"
The specified module could not be found.
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl .\libdl.jl:117
  [2] dlopen(s::String, flags::UInt32)
    @ Base.Libc.Libdl .\libdl.jl:116
  [3] macro expansion
    @ C:\Users\davidj\.julia\packages\JLLWrappers\QpMQW\src\products\library_generators.jl:54 [inlined]
  [4] __init__ ()
    @ Cairo_jll C:\Users\davidj\.julia\packages\Cairo_jll\HW4xi\src\wrappers\x86_64-w64-mingw32.jl:18
  [5] _include_from_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any})
    @ Base .\loading.jl:925
  [6] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, sourcepath::String, depmods::Vector{Any})
    @ Base .\loading.jl:1032
  [7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt64)
    @ Base .\loading.jl:1122
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base .\loading.jl:1409
  [9] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1295
 [10] macro expansion
    @ .\loading.jl:1275 [inlined]
 [11] macro expansion
    @ .\lock.jl:267 [inlined]
 [12] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1238
 [13] top-level scope
    @ .\timing.jl:273 [inlined]
 [14] top-level scope
    @ .\REPL[1]:0
during initialization of module Cairo_jll

```

I can simplyfy it with the “reproducer” :

```julia
fn=joinpath(homedir(),raw".julia\artifacts\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\bin\libcairo-2.dll")
res_stat=stat(fn)
@show res_stat
res_dlopen=Base.Libc.Libdl.dlopen(fn)
@show res_dlopen

```

```julia
julia> fn=joinpath(homedir(),raw".julia\artifacts\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\bin\libcairo-2.dll")
"C:\\Users\\davidj\\.julia\\artifacts\\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\\bin\\libcairo-2.dll"

julia> res_stat=stat(fn)
StatStruct for "C:\\Users\\davidj\\.julia\\artifacts\\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\\bin\\libcairo-2.dll"
   size: 10316921 bytes
 device: 3531273235
  inode: 956946
   mode: 0o100666 (-rw-rw-rw-)
  nlink: 1
    uid: 0
    gid: 0
   rdev: 0
  blksz: 4096
 blocks: 20152
  mtime: (24 days ago)
  ctime: (24 days ago)

julia> @show res_stat
res_stat = StatStruct("C:\\Users\\davidj\\.julia\\artifacts\\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\\bin\\libcairo-2.dll" size: 10316921 bytes device: 3531273235 inode: 956946 mode: 0o100666 (-rw-rw-rw-) nlink: 1 uid: 0 gid: 0 rdev: 0 blksz: 4096 blocks: 20152 mtime: (24 days ago) ctime: (24 days ago))
StatStruct for "C:\\Users\\davidj\\.julia\\artifacts\\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\\bin\\libcairo-2.dll"
   size: 10316921 bytes
 device: 3531273235
  inode: 956946
   mode: 0o100666 (-rw-rw-rw-)
  nlink: 1
    uid: 0
    gid: 0
   rdev: 0
  blksz: 4096
 blocks: 20152
  mtime: (24 days ago)
  ctime: (24 days ago)

julia> res_dlopen=Base.Libc.Libdl.dlopen(fn)
ERROR: could not load library "C:\Users\davidj\.julia\artifacts\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\bin\libcairo-2.dll"
The specified module could not be found.
Stacktrace:
 [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
   @ Base.Libc.Libdl .\libdl.jl:117
 [2] dlopen
   @ .\libdl.jl:116 [inlined]
 [3] dlopen(s::String)
   @ Base.Libc.Libdl .\libdl.jl:116
 [4] top-level scope
   @ REPL[5]:1

julia> @show res_dlopen
ERROR: UndefVarError: `res_dlopen` not defined
Stacktrace:
 [1] top-level scope
   @ show.jl:1128

```

Works OK in julia-1.8.3 under Cygwin, OK in julia-1.9.0-alpha1 under Windows REPL/Terminal, but fails under Cygwin.  
Cygwin version :

```julia
davidj@vivojdw ~$ uname -a
CYGWIN_NT-10.0-22621 vivojdw 3.3.6-341.x86_64 2022-09-05 11:15 UTC x86_64 Cygwin

```

Julia-1.9.0-alpha1 version

```julia
julia> versioninfo()
Julia Version 1.9.0-alpha1
Commit 0540f9d739 (2022-11-15 14:37 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver1)
  Threads: 8 on 8 virtual cores
Environment:
  JULIA_EDITOR = "C:\Program Files\Notepad++\notepad++.exe"
  JULIA_NUM_THREADS = auto
  JULIA_PROJECT = @.

```

How to make it works, or how to get info on what is not working ?  
Thanks,

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [December 3, 2022, 2:49pm UTC](https://discourse.julialang.org/t/cygwin-mishap-with-julia-1-9-0-alpha1-plots-dlopen-cant-open-libcairo-2-dll/91179/2 "2022-12-03T14:49:33Z")

</div>

> [@jdad](#):
>
> I can simplyfy it with the “reproducer” :
> 
> ```julia
> fn=joinpath(homedir(),raw".julia\artifacts\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\bin\libcairo-2.dll")
> res_stat=stat(fn)
> @show res_stat
> res_dlopen=Base.Libc.Libdl.dlopen(fn)
> @show res_dlopen
> 
> ```

That’s not a great reproducer, that alone can’t possibly work if you don’t manually dlopen all dependencies beforehand anyway.

Instead, try this:

```julia
]add DependencyWalker Cairo_jll
using DependencyWalker
using Cairo_jll # This will fail, it's ok, but it's needed to load the dependencies
Library("C:\\Users\\davidj\\.julia\\artifacts\\3aff78028a0bb2ad40ebc3ae7e465a52dcbe2730\\bin\\libcairo-2.dll")

```

This should hopefully show what modules cannot be found.

---

<div class="post-metadata">

**Author:** ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)\
**Post date:** [December 4, 2022, 10:43am UTC](https://discourse.julialang.org/t/cygwin-mishap-with-julia-1-9-0-alpha1-plots-dlopen-cant-open-libcairo-2-dll/91179/3 "2022-12-04T10:43:51Z")

</div>

Many thanks for the help. Result is

```julia
  ✗ MSIMG32.dll (NOT FOUND)
  ✗ libssp-0.dll (NOT FOUND)

```

while they are found with the Windows-not-cygwin version. I suppose it is a PATH (or LD\_LIBRARY\_PATH, or similar) issue ? I will try to continue to understand this, but help is welcome.

By the way, I tried same on another computer, just-arrived-just-installed minisforum nucxi7, and it fails on the pure Windows(-pro) version, with exactly same diagnostic ? So it could be it is not specific to cygwin after all ?

very happy for your help,

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [December 4, 2022, 10:59am UTC](https://discourse.julialang.org/t/cygwin-mishap-with-julia-1-9-0-alpha1-plots-dlopen-cant-open-libcairo-2-dll/91179/4 "2022-12-04T10:59:45Z")

</div>

`MSIMG32.dll` is a Windows system library, if it isn’t available in your system there’s nothing we can do about it. According to [this Windows forum](https://answers.microsoft.com/en-us/windows/forum/all/dll-error-cwindowssystem32msimg32dll/9d78dbc4-f720-40f5-b866-d36d0c5569be), this library is part of the Microsoft Graphical Device Interface (GDI), do you have this component in your system?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 4, 2022, 1:05pm UTC](https://discourse.julialang.org/t/cygwin-mishap-with-julia-1-9-0-alpha1-plots-dlopen-cant-open-libcairo-2-dll/91179/5 "2022-12-04T13:05:12Z")

</div>

> [@jdad](#):
>
> `libssp-0.dll (NOT FOUND)`

I think this can happen if you install the Windows version that lacks certain media capabilities (like Windows Movie Player). Some required dlls are then not present. You should be able to install this into the existing installation though.

---

<div class="post-metadata">

**Author:** ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)\
**Post date:** [December 4, 2022, 2:10pm UTC](https://discourse.julialang.org/t/cygwin-mishap-with-julia-1-9-0-alpha1-plots-dlopen-cant-open-libcairo-2-dll/91179/6 "2022-12-04T14:10:50Z")

</div>

Thank @giordano and @kristoffer.carlsson for the answers !

In fact, on my **laptop** under cygwin I was shortening the cygwin `PATH` in the `.profile`, so both **ddl** s were not found. Now, with same path as Windows (plus /usr/bin, /home/bin, and similar, but no deletion), they are found as

```julia
MSIMG32.dll in C:\WINDOWS\SYSTEM32\MSIMG32.dll
libssp-0.dll in C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\libssp-0.dll

```

(as I have installed mingw64 also).

Note that, I suppose the right one should be in fact

```julia
C:\Users\davidj\AppData\Local\Programs\Julia-1.9.0-alpha1\bin\libssp-0.dll

```

? I then hope that this does not implies problem, of not using this latter one.

On the **nucxi7** whence it fails in pure Windows, as per your recommendation I will try to install GDI (or required media libs when I find the ones needed), and then see what happens and report it.

Many thanks to you both wonderful experts !
