Installing RMagick

675 views
Skip to first unread message

Bozhidar

unread,
Jul 7, 2011, 10:59:52 AM7/7/11
to RubyInstaller
I'm trying to install RMagick on Windows and I was following this
"tutorial" - http://stackoverflow.com/questions/4451213/ruby-1-9-2-how-to-install-rmagick-on-windows,
adapted for powershell:

$env:PATH="C:\ImageMagick-6.7.0-Q16;" + $env:PATH
$env:CPATH="C:\ImageMagick-6.7.0-Q16\include"
$env:LIBRARY_PATH="C:\ImageMagick-6.7.0-Q16\lib"

gem install rmagick

...

======================================================================
Thu 07Jul11 17:40:00
This installation of RMagick 2.13.1 is configured for
Ruby 1.9.2 (i386-mingw32) and ImageMagick 6.7.0
======================================================================

make
gcc -I. -IC:/Ruby192/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby192/
include/ruby-1.9.1/ruby/backward -I/C/Ruby192/include
ruby-1.9.1 -I. -DRUBY_EXTCONF_H=\"extconf.h\" -O3 -g -Wextra -Wno-
unused-parameter -Wno-parentheses -Wpointer-arith
Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o
rmagick.o -c rmagick.c
rmagick.c: In function 'Magick_colors':
rmagick.c:42:5: warning: passing argument 2 of 'GetColorInfoList' from
incompatible pointer type
................
C:\Ruby192\lib\ruby\gems\1.9.1\gems\rmagick-2.13.1\ext\RMagick/
rmutil.c:81: undefined reference to `RelinquishMagickMemo
ry'
rmutil.o: In function `magick_clone_string':
C:\Ruby192\lib\ruby\gems\1.9.1\gems\rmagick-2.13.1\ext\RMagick/
rmutil.c:152: undefined reference to `CloneString'
rmutil.o: In function `rm_get_property':
C:\Ruby192\lib\ruby\gems\1.9.1\gems\rmagick-2.13.1\ext\RMagick/
rmutil.c:858: undefined reference to `GetImageProperty'
rmutil.o: In function `rm_set_property':
C:\Ruby192\lib\ruby\gems\1.9.1\gems\rmagick-2.13.1\ext\RMagick/
rmutil.c:875: undefined reference to `SetImageProperty'
collect2: ld returned 1 exit status
make: *** [RMagick2.so] Error 1

=========

Seems to me that something is missing, but I have absolute no idea
what. Thanks in advance for your help.

Bozhidar Batsov

unread,
Jul 7, 2011, 11:18:03 AM7/7/11
to RubyInstaller
Btw doing it like this:

PS C:\Users\Bozhidar> gem install rmagick --platform=ruby -- -- --with-opt-lib=c:/ImageMagick-6.7.0-Q16/lib --with-opt-include=c:/ImageMagick-6.7.0-Q16/include

yields the same results.

I've read everything I could find on the net on the subject and still I cannot figure that one out...


--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To post to this group, send email to rubyin...@googlegroups.com.
To unsubscribe from this group, send email to rubyinstalle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyinstaller?hl=en.




--
Best Regards,
Bozhidar Batsov


Jon

unread,
Jul 7, 2011, 11:25:49 AM7/7/11
to rubyin...@googlegroups.com

When you installed ImageMagick you installed the libraries and headers, right? Also, which version of the DevKit?

Try changing LIBRARY_PATH to just C:\ImageMagick-6.7.0-Q16 and see if things work by allowing gcc to link against the *.dll files.

Jon

---
blog: http://jonforums.github.com/
twitter: @jonforums

"Anyone who can only think of one way to spell a word obviously lacks imagination." - Mark Twain

Bozhidar Batsov

unread,
Jul 7, 2011, 11:42:52 AM7/7/11
to rubyin...@googlegroups.com
Yep, I installed the dev headers and the libraries. I'm using the latest version of DevKit(http://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.1-20101214-1400-sfx.exe). Changing the library path does not work and does not make sense IMHO since I see that the dll's reside in that folder.

Best Regards,
Bozhidar


--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To post to this group, send email to rubyin...@googlegroups.com.
To unsubscribe from this group, send email to rubyinstalle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyinstaller?hl=en.

Jon

unread,
Jul 7, 2011, 11:51:49 AM7/7/11
to rubyin...@googlegroups.com
> Yep, I installed the dev headers and the libraries. I'm using the latest
> version of DevKit(
> http://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.1-20101214-1400-sfx.exe).
> Changing the library path does not work and does not make sense IMHO since I
> see that the dll's reside in that folder.

:(

Have you also looked at the two RMagic tuts at our wiki https://github.com/oneclick/rubyinstaller/wiki/Tutorials

Given that c:/ImageMagick-6.7.0-Q16/lib contains *.lib files I'd hoped that forcing the link against the *.dll's would have done the trick.

I'm guessing that the following won't work, but try it from a cmd.exe shell (without the env var mods) instead of PS. If it doesn't work, copy rmagick's ext/mkmf.log file to a pastie and reply with the link.

gem install rmagick --platform=ruby -- --with-opt-lib=c:\ImageMagick-6.7.0-Q16 --with-opt-include=c:\ImageMagick-6.7.0-Q16\include

Jon

unread,
Jul 7, 2011, 12:11:28 PM7/7/11
to rubyin...@googlegroups.com

C:\Users\Jon\Documents>set PATH=C:\ImageMagick-6.7.0-Q16;%PATH%

C:\Users\Jon\Documents>gem install rmagick --platform=ruby -- --with-opt-lib=c:\ImageMagick-6.7.0-Q16 --with-opt-include=c:\ImageMagick-6.7.0-Q16\include
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed rmagick-2.13.1
1 gem installed

But it's likely you're going to face runtime problems as the RMagick2.so is linked against ImageMagick's CORE_RL_magick_.dll (you'll need C:\ImageMagick-6.7.0-Q16 on PATH at runtime for the DLLs to be picked up) which is linked against a private MSVCR100.DLL. Since RMagick2.so is linked against MSVCRT.DLL this "linking against multiple CRT versions" issue will likely cause problems.

Bozhidar Batsov

unread,
Jul 7, 2011, 12:13:25 PM7/7/11
to rubyin...@googlegroups.com
Yes, I've read the two tutorials. The cmd.exe idea didn't work as well. Here the stuff you asked about:

This is what happens when I try to link to the ddls:

checking for Ruby version >= 1.8.5... -------------------- yes

--------------------

"gcc -o conftest -IC:/Ruby192/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby192/include/ruby-1.9.1/ruby/backward -IC:/Ruby192/include/ruby-1.9.1 -I.     -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long conftest.c  -L. -LC:/Ruby192/lib -L.    -lCORE_RL_magick_ -lX11  -lmsvcrt-ruby191-static  -lshell32 -lws2_32  "
C:/ImageMagick-6.7.0-Q16/CORE_RL_magick_.dll: file not recognized: File format not recognized
collect2: ld returned 1 exit status


checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main() {return 0;}
/* end */

====

The other log is much longer and I've attached it to this message.


--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To post to this group, send email to rubyin...@googlegroups.com.
To unsubscribe from this group, send email to rubyinstalle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyinstaller?hl=en.

mkmf.log

Bozhidar Batsov

unread,
Jul 7, 2011, 12:20:52 PM7/7/11
to rubyin...@googlegroups.com
This is most strange. I'm executing exactly the same commands in cmd.exe and I get a compilation error :-) I guess it was a bad decision to try to use windows as a Ruby dev platform in the first place. I've wasted far too much time for stuff that is trivial in an Unix OS and I should probably start using one right about now :-)

Thanks for the help, though.

Best Regards,
Bozhidar

--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To post to this group, send email to rubyin...@googlegroups.com.
To unsubscribe from this group, send email to rubyinstalle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyinstaller?hl=en.

Jon

unread,
Jul 7, 2011, 12:44:38 PM7/7/11
to rubyin...@googlegroups.com
> This is most strange. I'm executing exactly the same commands in cmd.exe and
> I get a compilation error :-) I guess it was a bad decision to try to use
> windows as a Ruby dev platform in the first place. I've wasted far too much
> time for stuff that is trivial in an Unix OS and I should probably start
> using one right about now :-)
>
> ...SNIP...

>
> > C:\Users\Jon\Documents>set PATH=C:\ImageMagick-6.7.0-Q16;%PATH%
> >
> > C:\Users\Jon\Documents>gem install rmagick --platform=ruby --
> > --with-opt-lib=c:\ImageMagick-6.7.0-Q16
> > --with-opt-include=c:\ImageMagick-6.7.0-Q16\include
> > Temporarily enhancing PATH to include DevKit...
> > Building native extensions. This could take a while...
> > Successfully installed rmagick-2.13.1
> > 1 gem installed
> >
> > But it's likely you're going to face runtime problems as the RMagick2.so is
> > linked against ImageMagick's CORE_RL_magick_.dll (you'll need
> > C:\ImageMagick-6.7.0-Q16 on PATH at runtime for the DLLs to be picked up)
> > which is linked against a private MSVCR100.DLL. Since RMagick2.so is linked
> > against MSVCRT.DLL this "linking against multiple CRT versions" issue will
> > likely cause problems.

What's odd is I can build the gem fine and run RMagick's examples/vignette.rb and it properly generates a vignette.png. It gives an error trying to run display but the png is fine. Maybe the multiple CRT issue isn't a problem in this case. Don't know as I don't use RMagick.

Have you posted an issue at the http://github.com/rmagick/rmagick/issues I see https://github.com/rmagick/rmagick/issues/27 but don't know if that's you.

Don't give up just yet since it seems RMagick can build with our DevKit. And even though the multiple CRT issue is a concern, it may turn out to be OK. If you've got any more patience on this one I'd say push it a bit more with the RMagick folks ;)

And if they get things working and are building gems from *nix, please request that they build a fat binary (1.8/1.9) binary gem with Luis' http://rubygems.org/gems/rake-compiler like Nokogiri and others are doing.

Bozhidar Batsov

unread,
Jul 7, 2011, 12:51:54 PM7/7/11
to rubyin...@googlegroups.com
The problem is that I have deadlines to catch :-) I've wasted half a day battling what usually took me 30 seconds in most Linux distros. Native extensions continue to be Windows's Achilles's heel as far as Ruby development is concerned. I'll see if I can come up with some solution by the morning, otherwise Debian will make a triumphant appearance on my work pc :-)

Best Regards,
Bozhidar

--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To post to this group, send email to rubyin...@googlegroups.com.
To unsubscribe from this group, send email to rubyinstalle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyinstaller?hl=en.

Jon

unread,
Jul 7, 2011, 1:04:18 PM7/7/11
to rubyin...@googlegroups.com
> The problem is that I have deadlines to catch :-) I've wasted half a day
> battling what usually took me 30 seconds in most Linux distros. Native
> extensions continue to be Windows's Achilles's heel as far as Ruby
> development is concerned. I'll see if I can come up with some solution by
> the morning, otherwise Debian will make a triumphant appearance on my work
> pc :-)

Understood.

If you _do_ get time to come back to it, create a http://pastie.org/ of the mkmf.log from the failed build as well as your PATH and the output of `gem env`.

You might also check out our https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting page (especially the wacky one about AutoRun entries) and see if any of these help. And maybe a more experienced RMagick user will grace this thread ;)

http://www.virtualbox.org/ + http://www.archlinux.org/ is my favorite combo on Win7.

Luis Lavena

unread,
Jul 7, 2011, 2:15:25 PM7/7/11
to rubyin...@googlegroups.com
On Thu, Jul 7, 2011 at 11:59 AM, Bozhidar <bozhida...@gmail.com> wrote:
> I'm trying to install RMagick on Windows and I was following this
> "tutorial" - http://stackoverflow.com/questions/4451213/ruby-1-9-2-how-to-install-rmagick-on-windows,
> adapted for powershell:
>

Dunno how PowerShell works, but I know that Ruby uses COMSPEC to fire
child process.

If COMSPEC is set to PowerShell, expect issues as I was checking
Ruby's source code and it doesn't consider anything beyond cmd.exe to
run these child processes.

To answer your installation issues:

http://stackoverflow.com/questions/6473853/ruby-on-rails-rmagick-on-windows-7/6477787#6477787
https://github.com/oneclick/rubyinstaller/wiki/Tutorials
http://phosphor-escence.blogspot.com/2010/10/install-rmagick-on-mingw-and-msys.html
http://www.waydotnet.com/blog/2010/02/rmagick-on-ruby-1-9-1-i386-mingw32-work-d/

In the stack overflow article I do mention that RMagick can't be
installed using the gem because does not work with Ruby 1.9.2

Please read the thread that is linked from there.

--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Bozhidar Batsov

unread,
Jul 7, 2011, 3:06:09 PM7/7/11
to rubyin...@googlegroups.com
I've already read all of the links you've mentioned (I wouldn't have bothered you with my question if I hadn't done enough of a research first) plus a few more :-). I did notice some comments mentioning successful installations with 1.9.2 so I assumed it was possible. 

Best Regards,
Bozhidar

--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To post to this group, send email to rubyin...@googlegroups.com.
To unsubscribe from this group, send email to rubyinstalle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyinstaller?hl=en.

Luis Lavena

unread,
Jul 7, 2011, 3:15:13 PM7/7/11
to rubyin...@googlegroups.com
On Thu, Jul 7, 2011 at 4:06 PM, Bozhidar Batsov
<bozhida...@gmail.com> wrote:
> I've already read all of the links you've mentioned (I wouldn't have
> bothered you with my question if I hadn't done enough of a research first)
> plus a few more :-). I did notice some comments mentioning successful
> installations with 1.9.2 so I assumed it was possible.

It is not possible with latest gem, as I mentioned in a thread in the
list, you need to checkout the source code and build the gem and then
install from it.

Also, instead of playing with env variables on PowerShell, you could
use the extra parameters of RubyGems (after the two dashes) that did
work for me several times in the past.

Bozhidar Batsov

unread,
Jul 8, 2011, 3:50:07 AM7/8/11
to rubyin...@googlegroups.com
Thank for all the help, guys. Because of you my windows dev box will live to see another day. I have found the error of my ways - I had mistakenly installed a 64bit imagemagick.

Btw, Luis, the latest rmagick gem got compiled just fine with 1.9.2.

Best Regards,
Bozhidar

--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To post to this group, send email to rubyin...@googlegroups.com.
To unsubscribe from this group, send email to rubyinstalle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyinstaller?hl=en.

WaYdotNET la potenza del .NET nelle mani di Carlo

unread,
Jul 8, 2011, 4:32:52 AM7/8/11
to rubyin...@googlegroups.com

2011/7/8 Bozhidar Batsov <bozhida...@gmail.com>

Thank for all the help, guys. Because of you my windows dev box will live to see another day. I have found the error of my ways - I had mistakenly installed a 64bit imagemagick.

Btw, Luis, the latest rmagick gem got compiled just fine with 1.9.2.

Good notice, thx



--
WaYdotNET ... pura potenza  .NET !!!!
www.waydotnet.com => personal website/blog/repository
www.waydotnet.com/photogallery => photogallery :D
Reply all
Reply to author
Forward
0 new messages