rmagick with 1.9

1,148 views
Skip to first unread message

rogerdpack

unread,
Nov 19, 2009, 8:18:21 PM11/19/09
to RubyInstaller
If anybody else is looking for it, here are instructions on how to
build rmagick with mingw 1.9 [unfortunately it requires first
installing ImageMagick from source to somewhere, but we do what we
can].
http://betterlogic.com/roger/?p=2186
Thanks.
-r

Luis Lavena

unread,
Nov 19, 2009, 9:46:03 PM11/19/09
to rubyin...@googlegroups.com
Thank you Roger,

RMagick is a complete beast that require lot of work to get it
compile. I highly advise against building it on your own.

Long ago I moved to mini_magick and command line tools usage instead.
Don't miss RMagick functionality as I don't do image processing.

But others will find this useful.
--
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

Alexey Borzenkov

unread,
Nov 20, 2009, 1:06:57 AM11/20/09
to rubyin...@googlegroups.com
On Fri, Nov 20, 2009 at 5:46 AM, Luis Lavena <luisl...@gmail.com> wrote:
> RMagick is a complete beast that require lot of work to get it
> compile. I highly advise against building it on your own.

I disagree. Ever since mingw checks were accepted upstream it's as
simple as this:

set CPATH=<ImageMagick>\include
set LIBRARY_PATH=<ImageMagick>\lib
gem install rmagick --platform ruby

You don't even need to compile ImageMagick from source.

rogerdpack

unread,
Nov 20, 2009, 6:34:29 PM11/20/09
to RubyInstaller
> I disagree. Ever since mingw checks were accepted upstream it's as
> simple as this:
>
> set CPATH=<ImageMagick>\include
> set LIBRARY_PATH=<ImageMagick>\lib
> gem install rmagick --platform ruby
>
> You don't even need to compile ImageMagick from source.

Interesting. Perhaps you can describe the steps in more detail--don't
you still need the dll's on your system? Do you download the .tar.gz
and point it at that? why would set LIBRARY_PATH=<ImageMagick>\lib
be useful if you haven't built yet?
Much thanks.
-r

Alexey Borzenkov

unread,
Nov 21, 2009, 4:48:34 AM11/21/09
to rubyin...@googlegroups.com
On Sat, Nov 21, 2009 at 2:34 AM, rogerdpack <rogerp...@gmail.com> wrote:
> Interesting. Perhaps you can describe the steps in more detail--don't
> you still need the dll's on your system?  Do you download the .tar.gz
> and point it at that?  why would  set LIBRARY_PATH=<ImageMagick>\lib
> be useful if you haven't built yet?
> Much thanks.

I do it this way:

- install using official ImageMagick installer for Windows
- set DFImageMagick environment variable to where I installed it
- set PATH=%DFImageMagick%;%PATH% (if you don't already have it in PATH)
- set CPATH=%DFImageMagick%\include;%CPATH%
- set LIBRARY_PATH=%DFImageMagick%\lib;%LIBRARY_PATH%
- gem install rmagick

CPATH/LIBRARY_PATH for gcc is what INCLUDE/LIB is for msvc. I use it
quite a lot, even on Mac OS X.

rogerdpack

unread,
Nov 23, 2009, 1:06:46 PM11/23/09
to RubyInstaller
> - install using official ImageMagick installer for Windows
Perhaps you can point me toward the exact download you use? Mine
doesn't seem to come with an include and lib path...
Thanks!
-r

Alexey Borzenkov

unread,
Nov 23, 2009, 1:53:17 PM11/23/09
to rubyin...@googlegroups.com
Did you install development headers/libraries? Although I must admit I
might be using a version ~4 months old (last time I updated was around
this posing: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=14437).
Unless they changing something there must be a way to install
development files...

Alexey Borzenkov

unread,
Nov 23, 2009, 2:10:47 PM11/23/09
to rubyin...@googlegroups.com
On Mon, Nov 23, 2009 at 9:06 PM, rogerdpack <rogerp...@gmail.com> wrote:
Ok, I just downloaded the latest version, installed with "Install
development blabla for C and C++" checkbox enabled, then with
msys/mingw in my PATH:

C:\> set PATH=C:\Program Files\ImageMagick-6.5.7-Q8;%PATH%
C:\> set CPATH=C:\Program Files\ImageMagick-6.5.7-Q8\include
C:\> set LIBRARY_PATH=C:\Program Files\ImageMagick-6.5.7-Q8\lib
C:\> gem install rmagick

...and it failed to build, because there's no DestroyConstitute
function anymore. Must be some API change. :-/

Luis Lavena

unread,
Nov 23, 2009, 2:15:34 PM11/23/09
to rubyin...@googlegroups.com
On Mon, Nov 23, 2009 at 4:10 PM, Alexey Borzenkov <sna...@gmail.com> wrote:
>
> Ok, I just downloaded the latest version, installed with "Install
> development blabla for C and C++" checkbox enabled, then with
> msys/mingw in my PATH:
>

You need to download the exact same version for which RMagick was
built or package with.

If not, you will bump a lot of strange issues.

> ...and it failed to build, because there's no DestroyConstitute
> function anymore. Must be some API change. :-/

Definitely sounds like that :P

Alexey Borzenkov

unread,
Nov 23, 2009, 3:35:29 PM11/23/09
to rubyin...@googlegroups.com
On Mon, Nov 23, 2009 at 10:15 PM, Luis Lavena <luisl...@gmail.com> wrote:
>> ...and it failed to build, because there's no DestroyConstitute
>> function anymore. Must be some API change. :-/
> Definitely sounds like that :P

Seems it can be fixed by something like this:

diff --git a/ext/RMagick/extconf.rb b/ext/RMagick/extconf.rb
index 8d57d1c..cc449c8 100644
--- a/ext/RMagick/extconf.rb
+++ b/ext/RMagick/extconf.rb
@@ -221,7 +221,8 @@ have_func("snprintf", headers)
"SparseColorImage", # 6.3.6-?
"SyncAuthenticPixels", # 6.4.5-6
"TransparentPaintImage", # 6.3.7-10
- "TransparentPaintImageChroma" # 6.4.5-6
+ "TransparentPaintImageChroma", # 6.4.5-6
+ "ConstituteImage"
].each do |func|
have_func(func, headers)
end
diff --git a/ext/RMagick/rmimage.c b/ext/RMagick/rmimage.c
index 5a485fc..6796d3f 100644
--- a/ext/RMagick/rmimage.c
+++ b/ext/RMagick/rmimage.c
@@ -3052,8 +3052,12 @@ Image_constitute(VALUE class, VALUE width_arg,
VALUE height_arg
}
}

+#ifdef HAVE_CONSTITUTEIMAGE
GetExceptionInfo(&exception);
-
+ image = ConstituteImage(width, height, map, stg_type, (const void
*)pixels.v, &exception);
+ CHECK_EXCEPTION();
+ (void) DestroyExceptionInfo(&exception);
+#else
// This is based on ConstituteImage in IM 5.5.7
image = AcquireImage(NULL);
if (!image)
@@ -3071,8 +3075,8 @@ Image_constitute(VALUE class, VALUE width_arg,
VALUE height_arg
xfree(pixels.v);
rm_check_image_exception(image, DestroyOnError);

- (void) DestroyExceptionInfo(&exception);
DestroyConstitute();
+#endif

return rm_image_new(image);
}

Alexey Borzenkov

unread,
Nov 23, 2009, 3:41:56 PM11/23/09
to rubyin...@googlegroups.com
On Mon, Nov 23, 2009 at 10:15 PM, Luis Lavena <luisl...@gmail.com> wrote:
> On Mon, Nov 23, 2009 at 4:10 PM, Alexey Borzenkov <sna...@gmail.com> wrote:
>> Ok, I just downloaded the latest version, installed with "Install
>> development blabla for C and C++" checkbox enabled, then with
>> msys/mingw in my PATH:
> You need to download the exact same version for which RMagick was
> built or package with.

That's if you are using binary gem. But I'm installing gems with
--platform ruby (I always forget to mention that I have it in my
.gemrc :-/). ImageMagick seems pretty volatile about backwards
compatibility though, on the other hand I couldn't find where you can
download older ImageMagick versions on their site.

> If not, you will bump a lot of strange issues.

That's the first time I bumped into something like this. And I think
this happens because interfaces should either be private (if you are
not supposed to use it), or not getting renamed out of the blue
(searching for this function name shows it was renamed maybe twice or
trice).

rogerdpack

unread,
Nov 25, 2009, 11:24:49 AM11/25/09
to RubyInstaller
> Did you install development headers/libraries?

Wow for some reason I missed that option. Silly me.

> ...and it failed to build, because there's no DestroyConstitute

Yeah I messaged the RMagick guys about that and they said "API change"
and that they'd fixed it in their CVS trunk.

So this continues to raise the interesting question.

With something like rmagick that has a binary dependency [you need to
download ImageMagick before hand], what can be a "good" automated way
to make this happen? It sounds similar to the question about a
dependency on ActiveTcl 8.4

DSL stuff, perhaps?
-r

Luis Lavena

unread,
Nov 25, 2009, 2:16:59 PM11/25/09
to rubyin...@googlegroups.com
On Wed, Nov 25, 2009 at 1:24 PM, rogerdpack <rogerp...@gmail.com> wrote:
> [...]
>
> So this continues to raise the interesting question.
>
> With something like rmagick that has a binary dependency [you need to
> download ImageMagick before hand], what can be a "good" automated way
> to make this happen? It sounds similar to the question about a
> dependency on ActiveTcl 8.4
>
> DSL stuff, perhaps?

Sounds a good candidate, at least in this case.

The case of Ruby Tk is different, since the extension needs the
dependencies at ruby build-time, while RMagick needs the deps at
installation.

Alexey Borzenkov

unread,
Nov 25, 2009, 4:01:56 PM11/25/09
to rubyin...@googlegroups.com
On Wed, Nov 25, 2009 at 10:16 PM, Luis Lavena <luisl...@gmail.com> wrote:
> The case of Ruby Tk is different, since the extension needs the
> dependencies at ruby build-time, while RMagick needs the deps at
> installation.

Actually, I just checked, and with 1.9 you can install tk as a third
party extension. For example, I extracted ext/tk from ruby-1.9.1-p243,
and:

ruby extconf.rb --with-tcl-dir=C:/Tcl --with-tk-dir=C:/Tcl
make install
cd tkutil
ruby extconf.rb
make install

Tk will be installed in site_ruby and appears to work afterwards.

Unfortunately, with 1.8.6 I couldn't make it work with Tcl 8.5.8 even
with a patch backported from 1.8.7:

http://git.kitsu.ru/patched/ruby-1.8.6.git?a=commitdiff;h=5ef6ab7fb070474c1c25b31c3ab74fbe8eb9258d

It compiles, but many samples crash afterwards, perhaps more porting
would be needed to support 8.5 (and tkutil from 1.8.7 doesn't build on
1.8.6)...
Reply all
Reply to author
Forward
0 new messages