Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not open library 'libvips-42.dll': Failed with error 127: Procedure not found #379

Closed
HuBandiT opened this issue Dec 10, 2023 · 10 comments
Labels

Comments

@HuBandiT
Copy link

Greetings there,

Describe the bug
I am on Win10, RubyInstaller-devkit-3.2.2-1 and I must have some installation issue because even though ruby-vips is specified in my Gemfile and bundler runs and says everything is installed, the gem does not load:

To Reproduce

Steps to reproduce the behaviour:

irb(main):001:0> require 'vips'
 (LoadError)4/lib/ruby/gems/3.2.0/gems/ffi-1.16.3-x64-mingw-ucrt/lib/ffi/dynamic_library.rb:65:in `load_library': Could not open library 'libvips-42.dll': Failed with error 127: [localized message that roughly translates to: "The specified procedure could not be/was not found."]
.
Searched in <system library path>, /usr/lib, /usr/local/lib, /opt/local/lib
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ffi-1.16.3-x64-mingw-ucrt/lib/ffi/library.rb:95:in `block in ffi_lib'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ffi-1.16.3-x64-mingw-ucrt/lib/ffi/library.rb:94:in `map'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ffi-1.16.3-x64-mingw-ucrt/lib/ffi/library.rb:94:in `ffi_lib'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ruby-vips-2.2.0/lib/vips.rb:573:in `<module:Vips>'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ruby-vips-2.2.0/lib/vips.rb:570:in `<top (required)>'
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:40:in `require'
        from (irb):1:in `<main>'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
        from C:/Ruby32-x64/bin/irb:33:in `load'
        from C:/Ruby32-x64/bin/irb:33:in `<main>'
<internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require': cannot load such file -- vips (LoadError)
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
        from (irb):1:in `<main>'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
        from C:/Ruby32-x64/bin/irb:33:in `load'
        from C:/Ruby32-x64/bin/irb:33:in `<main>'
irb(main):002:0>

Expected behaviour
The vips gem should load without error and provide access to using the VIPS library.

Desktop (please complete the following information):
Win10, RubyInstaller-devkit:

>ridk version
---
ruby:
  path: C:/Ruby32-x64
  version: 3.2.2
  platform: x64-mingw-ucrt
  cc: gcc.exe (Rev10, Built by MSYS2 project) 12.2.0
ruby_installer:
  package_version: 3.2.2-1
  git_commit: 83df213
msys2:
  path: C:\Ruby32-x64\msys64
cc: gcc (Rev3, Built by MSYS2 project) 13.2.0
sh: GNU bash, 5.2.21(1)-release (x86_64-pc-msys) verzió
os: Microsoft Windows [Version 10.0.19045.3693]

Additional context

>pacman -Q -s vips
local/mingw-w64-ucrt-x86_64-libvips 8.15.0-1
    A fast image processing library with low memory needs (mingw-w64)
>pacman -Q -l mingw-w64-ucrt-x86_64-libvips
mingw-w64-ucrt-x86_64-libvips /ucrt64/
mingw-w64-ucrt-x86_64-libvips /ucrt64/bin/
mingw-w64-ucrt-x86_64-libvips /ucrt64/bin/libvips-42.dll
mingw-w64-ucrt-x86_64-libvips /ucrt64/bin/libvips-cpp-42.dll
mingw-w64-ucrt-x86_64-libvips /ucrt64/bin/vips.exe
mingw-w64-ucrt-x86_64-libvips /ucrt64/bin/vipsedit.exe
mingw-w64-ucrt-x86_64-libvips /ucrt64/bin/vipsheader.exe
mingw-w64-ucrt-x86_64-libvips /ucrt64/bin/vipsprofile
mingw-w64-ucrt-x86_64-libvips /ucrt64/bin/vipsthumbnail.exe
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/almostdeprecated.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/arithmetic.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/basic.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/buf.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/colour.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/connection.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/conversion.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/convolution.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/create.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/dbuf.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/debug.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/deprecated.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/dispatch.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/draw.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/enumtypes.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/error.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/foreign.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/format.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/freqfilt.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/gate.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/generate.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/header.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/histogram.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/image.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/interpolate.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/intl.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/mask.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/memory.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/morphology.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/mosaicing.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/object.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/operation.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/private.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/rect.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/region.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/resample.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/sbuf.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/semaphore.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/thread.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/threadpool.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/transform.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/type.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/util.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/VConnection8.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/vector.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/VError8.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/version.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/video.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/VImage8.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/VInterpolate8.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/vips.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/vips7compat.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/vips8
mingw-w64-ucrt-x86_64-libvips /ucrt64/include/vips/VRegion8.h
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/girepository-1.0/
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/girepository-1.0/Vips-8.0.typelib
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/libvips-cpp.dll.a
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/libvips.dll.a
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/pkgconfig/
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/pkgconfig/vips-cpp.pc
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/pkgconfig/vips.pc
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/vips-modules-8.15/
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/vips-modules-8.15/vips-heif.dll
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/vips-modules-8.15/vips-jxl.dll
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/vips-modules-8.15/vips-magick.dll
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/vips-modules-8.15/vips-openslide.dll
mingw-w64-ucrt-x86_64-libvips /ucrt64/lib/vips-modules-8.15/vips-poppler.dll
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/gir-1.0/
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/gir-1.0/Vips-8.0.gir
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/locale/
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/locale/de/
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/locale/de/LC_MESSAGES/
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/locale/de/LC_MESSAGES/vips8.15.mo
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/locale/en_GB/
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/locale/en_GB/LC_MESSAGES/
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/locale/en_GB/LC_MESSAGES/vips8.15.mo
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/man/
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/man/man1/
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/man/man1/vips.1.gz
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/man/man1/vipsedit.1.gz
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/man/man1/vipsheader.1.gz
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/man/man1/vipsprofile.1.gz
mingw-w64-ucrt-x86_64-libvips /ucrt64/share/man/man1/vipsthumbnail.1.gz
>set
ACLOCAL_PATH=/ucrt64/share/aclocal:/usr/share/aclocal
ALLUSERSPROFILE=C:\ProgramData
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
ComSpec=C:\Windows\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
HOMEDRIVE=C:
IOLIBS=C:\Program Files\darktable\lib\libgphoto2_port\0.12.0
MAGICK_HOME=C:\Program Files\darktable\lib\GraphicsMagick-1.3.36\modules-Q8\coders
MANPATH=/ucrt64/share/man
MINGW_CHOST=x86_64-w64-mingw32
MINGW_PACKAGE_PREFIX=mingw-w64-ucrt-x86_64
MINGW_PREFIX=/ucrt64
MSYSTEM=UCRT64
MSYSTEM_CARCH=x86_64
MSYSTEM_CHOST=x86_64-w64-mingw32
MSYSTEM_PREFIX=/ucrt64
NUMBER_OF_PROCESSORS=8
OPCODE6DIR64=C:\Program Files\Csound6_x64\plugins64\
OS=Windows_NT
Path=C:\Ruby32-x64\bin;C:\Ruby32-x64\msys64\ucrt64\bin;C:\Ruby32-x64\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Ruby32-x64\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW
PKG_CONFIG_PATH=/ucrt64/lib/pkgconfig:/ucrt64/share/pkgconfig
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
PROMPT=$P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
RI_DEVKIT=C:\Ruby32-x64\msys64
RUBY_DLL_PATH=C:\Ruby32-x64\msys64\ucrt64\bin
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
windir=C:\Windows

The Windows-visible path C:\Ruby32-x64\msys64\ucrt64\bin (in RUBY_DLL_PATH above) corresponds to the same directory, as the RubyInstaller/pacman-visible /ucrt64/bin/ directory.

Sadly I do not see anywhere the name of the procedure that could not be found.

Any suggestions?

Thank you kindly in advance.

(My apologies: this feels a lot like #118 again, but I don't develop much on Windows, so I am not sure where to start.)

@HuBandiT HuBandiT added the bug label Dec 10, 2023
@jcupitt
Copy link
Member

jcupitt commented Dec 10, 2023

Hi @HuBandiT,

I'm not so good on Windows either. I did get ruby-vips working on win10 last year sometime when I needed it for a small project and I think it was straightforward, but of course something may have happened since then.

I'll try again and see what happens.

@jcupitt
Copy link
Member

jcupitt commented Dec 10, 2023

I tried reinstalling ruby on win10 and it failed :( I'm pretty sure this was working last year, so I guess there's been a regression.

It's failing on the libvips DLL load which means it's managed to load libglib and libgobject successfully. I don't think there's a path issue, it must be some symbol in libvips which is not being resolved correctly. I wish it told us the name of the missing symbol. Perhaps it's libintl again?

I'm out of time today, I'll look again tomorrow.

@jcupitt
Copy link
Member

jcupitt commented Dec 10, 2023

(@kleisauke please don't spend any time investigating, but I don't suppose you have any immediate ideas what it might be?)

@kleisauke
Copy link
Member

Perhaps this is the same issue as the one mentioned in #364 (comment)? I'm not sure if that was ever fixed by MSYS2, I'll have a look.

@jcupitt
Copy link
Member

jcupitt commented Dec 10, 2023

I tried quickly and neither of those workarounds (adding the extra pacman packages or removing the modules dir) did the trick :(

@kleisauke
Copy link
Member

Enabling the "Show loader snaps" flag on the Ruby interpreter with:

"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\gflags.exe" -i C:\Ruby32-x64\bin\ruby.exe +sls

And when opening C:\Ruby32-x64\bin\ruby.exe -e "require 'vips'" in a debug session with WinDbg, I see:

2b18:11a4 @ 08853640 - LdrpNameToOrdinal - WARNING: Procedure "SSL_get0_group_name" could not be located in DLL at base 0x00007FFA739C0000.
2b18:11a4 @ 08853640 - LdrpReportError - ERROR: Locating export "SSL_get0_group_name" for DLL "C:\Ruby32-x64\msys64\ucrt64\bin\libcurl-4.dll" failed with status: 0xc0000139.
(2b18.11a4): Unknown exception - code c0000139 (first chance)
2b18:11a4 @ 08853640 - LdrpGenericExceptionFilter - ERROR: Function LdrpSnapModule raised exception 0xc0000139
	Exception record: .exr 0000007EB3BFE5F0
	Context record: .cxr 0000007EB3BFE100

So, it looks like a clash between OpenSSL 3.1.0 (provided by C:\Ruby32-x64\bin\ruby_builtin_dlls\libssl-3-x64.dll) and OpenSSL 3.2.0 (provided by C:\Ruby32-x64\msys64\ucrt64\bin\libssl-3-x64.dll) where only the latter DLL has the SSL_get0_group_name symbol available.

@larskanis Can I ping you for this? Would upgrading OpenSSL to 3.2.0 in RubyInstaller fix this?

Another option would be to disable Matlab support in the MSYS2 package of libvips, since libcurl is required by libhdf5, on which libmatio depends.

@larskanis
Copy link
Contributor

Thanks for doing the debugging! Answering from memory, this looks like a kind of oneclick/rubyinstaller2#60 . I'll check if I can make a new release of RubyInstaller-3.2 updating to OpenSSL-3. Unfortunately all older RubyInstaller are bound to OpenSSL-1.1 since OpenSSL-3 breaks the API on the ruby level, so that they will not be upgraded.

Another option should be to exchange the libcrypto.dll and libssl.dll of RubyInstaller-3.2 manually to the newer OpenSSL-3.2 version. Did you try this?

@kleisauke
Copy link
Member

Another option should be to exchange the libcrypto.dll and libssl.dll of RubyInstaller-3.2 manually to the newer OpenSSL-3.2 version. Did you try this?

Ah, I only tried to swap libssl-3-x64.dll with the newer one, which didn't work. I can confirm that swapping both libcrypto-3-x64.dll and libssl-3-x64.dll with the corresponding OpenSSL 3.2.0 DLLs fixes this issue.

@HuBandiT
Copy link
Author

HuBandiT commented Dec 10, 2023

Thank you for your efforts, everyone!

Replacing:

  • C:\Ruby32-x64\bin\ruby_builtin_dlls\libssl-3-x64.dll with C:\Ruby32-x64\msys64\ucrt64\bin\libssl-3-x64.dll, and
  • C:\Ruby32-x64\bin\ruby_builtin_dlls\libcrypto-3-x64.dll with C:\Ruby32-x64\msys64\ucrt64\bin\libcrypto-3-x64.dll

now allows the gem to load (although with warnings):

>irb
irb(main):001:0> require 'vips'

(process:16808): VIPS-WARNING **: 18:17:56.872: unable to load "C:\Ruby32-x64\msys64\ucrt64/lib/vips-modules-8.15\vips-jxl.dll" -- 'C:\Ruby32-x64\msys64\ucrt64/lib/vips-modules-8.15\vips-jxl.dll': [here a localized translation of "The specified module cannot be found."]

(process:16808): VIPS-WARNING **: 18:17:56.882: unable to load "C:\Ruby32-x64\msys64\ucrt64/lib/vips-modules-8.15\vips-openslide.dll" -- 'C:\Ruby32-x64\msys64\ucrt64/lib/vips-modules-8.15\vips-openslide.dll': [here a localized translation of "The specified module cannot be found."]
=> true

(I notice path separators in those paths are a mixed bunch of / and \...)

I do not intend to use JPEG-XL or OpenSlide (as such), so I hope this will still give me enough VIPS functionality to progress with what I am doing.

I'm available for further testing, if you guys want to hammer this out.

@HuBandiT
Copy link
Author

Turns out I merely did not have those two modules installed. After installing them by:

pacman -S mingw-w64-ucrt-x86_64-openslide
pacman -S mingw-w64-ucrt-x86_64-libjxl

the warnings are now gone and VIPS works!

Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants