Closed bradkrane closed 10 months ago
Hi! I was able to get into this but unfotunately, I don't have the full understanding of the setup to be able to help, so we will need some help from someone else also.
First: I did ridk enable
and then ridk exec pacman -S mingw-w64-x86_64-libexif
which installed exif into: C:\Ruby31-x64\msys64\mingw64 (lib, include\libexif).
I looked through running make --trace
and found that the include paths were:
-I.
-I/C/Ruby31-x64/include/ruby-3.1.0/x64-mingw-ucrt
-I/C/Ruby31-x64/include/ruby-3.1.0/ruby/backward
-I/C/Ruby31-x64/include/ruby-3.1.0
This excluded C:\Ruby31-x64\msys64\mingw64\include\
under which libexif
has the files that are needed. I temporarily edited the Makefile to include the above path:
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) -I /C/Ruby31-x64/msys64/mingw64/include
It now compiled but did not still failed to build. The trace showed that the lib path did not include the path where the libexif.a
existed. Again, I patched the Makefile to include C:\Ruby31-x64\msys64\mingw64\lib
LIBPATH = -L. -L$(libdir) -L/C/Ruby31-x64/msys64/mingw64/lib
The final issue was that -lexif
was not in the list of libraries to build together (I think because extconf.rb did not find the library. So, again, I modified the Makefile:
LIBS = $(LIBRUBYARG_SHARED) -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi -lbcrypt -lexif
Finally, it builds.
I don't know what is the correct way to factor all this back into the extconf.rb
so that it works correctly - or if something else should have been done.
Hopefully someone can help based on the information that I have included.
@bradkrane
Ruby 3.2 is a 'ucrt' build, you installed the 'mingw' package.
Try pacman -S mingw-w64-ucrt-x86_64-libexif
I'm using Ruby master, and the gem installed properly.
EDIT: Starting with Ruby 3.1, RubyInstaller builds use the ucrt tool chain. So, the pacman 'prefix' for Ruby 3.0 and earlier is
mingw-w64-x86_64-
. For Ruby 3.1 and later, the prefix is mingw-w64-ucrt-x86_64-
.
I just installed the gem using Ruby 3.2, and it also installed.
I guess that was the missing link in my investigation. Thanks for correcting that.
What's the correct way for:
Gem owners can add something similar to the below to their gemspec:
if spec.respond_to?(:metadata=)
spec.metadata ||= {}
spec.metadata["msys2_mingw_dependencies"] = "libexif"
end
I believe it is possible to have a version constraint on the package.
Otherwise, it's up to the person installing the gem.
Thanks, I will try to document this some place.
@MSP-Greg
Try
pacman -S mingw-w64-ucrt-x86_64-libexif
That did it, thanks for the help.
I've opened bradkrane/exif#1 with the gem to add the mingw libexif dependency.
Correction pull request tonytonyjan/exif#34
What problems are you experiencing?
Cannot
gem install exif
on Windows 10.0.19045Steps to reproduce
Install
rubyinstaller-devkit-3.2.2-1-x64.exe
Run:gem install exif
I've also tried
ridk exec pacman -S mingw-w64-x86_64-libexif
thengem install exif
&gem install exif --platform ruby -- --use-system-libraries
with same outcome. How can I correctly specify the path to the lib so it will compile or fix whatever is broken? Thanks!What's the output from
ridk version
?C:\Users\Brad Krane\Documents\src\exif>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 (Rev1, Built by MSYS2 project) 13.2.0 sh: GNU bash, version 5.2.15(1)-release (x86_64-pc-msys) os: Microsoft Windows [Version 10.0.19045.3208]
C:\Users\Brad Krane\Documents\src\exif>ruby -v ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]