Erro ao compilar o JMagick

Será que ninguém nunca compilo o JMagick???

Alguém pode me dar um help do por que o seguinte erro ocorre ao tentar compilar o JMagicK?

$ ./configure --with-java-home=/usr/lib/jvm/java-6-sun/ --with-java-includes=/usr/lib/jvm/java-6-sun/include/:/usr/lib/jvm/java-6-sun/include/linux/ --prefix=/home/paulopatto/Download/magick/ImageMagick
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for a BSD-compatible install... /usr/bin/install -c
checking for getconf... /usr/bin/getconf
checking whether large file support needs explicit enabling... yes
checking for X... libraries , headers 
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking jni.h usability... yes
checking jni.h presence... yes
checking for jni.h... yes
checking for java... /usr/bin/java
checking for javac... /usr/bin/javac
checking for javah... /usr/bin/javah
checking for jar... /usr/bin/jar
checking for javadoc... /usr/bin/javadoc
checking for Magick-config... /usr/local/bin/Magick-config
checking magick/api.h usability... no
checking magick/api.h presence... no
checking for magick/api.h... no
configure: error: 'Unable to find ImageMagick header files'
paulopatto@paulopatto-workstation:~/Download/magick/JMagick-6.2.6-0$

(*) Apenas uma observação, sim eu tenho o image magick compilado e instalado. Como tenho certeza?

$ convert --version
Version: ImageMagick 6.6.0-10 2010-09-01 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP 

Você não precisa ter esse arquivo magick/api.h em algum lugar da sua máquina ? Eu sei que ele está instalado (ou seja, você tem os binários, conforme pode-se ver pelo seu comando “convert”) mas não sei se você tem os headers do ImageMagick.

@entanglement obrigado pela resposta e bom dia.

Mas se falat esse cara, não sei como devo proceder, pois eu baixei os fonte e compilei ele… Conforme o link http://www.imagemagick.org/script/install-source.php#unix, bem eu vou ver isso nesta sexta-feira, pois tudo está no computador do trampo. Mas vou analisar isso com mais calma.

Obrigado

Sim eu tenho um arquivo chamado api.h mas ele está no ImageMagick ( /home/paulopatto/Download/magick/ImageMagick-6.6.0-10/magick/api.h ), veja como eu coloco o include na linha do configure

$ ./configure \
  --with-java-home=/usr/lib/jvm/java-6-sun/ \
  --with-java-includes=/usr/lib/jvm/java-6-sun/include/:/usr/lib \
  --with-magick-inc-dic=/home/paulopatto/Download/magick/ImageMagick-6.6.0-10/magick

Mas o erro continua o mesmo:

...
checking for Magick-config... /usr/local/bin/Magick-config
checking magick/api.h usability... no
checking magick/api.h presence... no
checking for magick/api.h... no
configure: error: 'Unable to find ImageMagick header files'

b [/b]referência que falava sobre compilar o image magick com a opção shared: http://studio.imagemagick.org/pipermail/magick-users/2002-January/000306.html

...
--with-magick-inc-dic=/home/paulopatto/Download/magick/ImageMagick-6.6.0-10
...

Mesmo erro.

paulopatto@paulopatto-workstation:~/Download/magick/JMagick-6.2.6-0$ ./configure --with-java-home=/usr/lib/jvm/java-6-sun/ --with-java-includes=/usr/lib/jvm/java-6-sun/include/:/usr/lib \--with-magick-inc-dic=/home/paulopatto/Download/magick/ImageMagick-6.6.0-10/
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for a BSD-compatible install... /usr/bin/install -c
checking for getconf... /usr/bin/getconf
checking whether large file support needs explicit enabling... yes
checking for X... libraries , headers 
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking jni.h usability... yes
checking jni.h presence... yes
checking for jni.h... yes
checking for java... /usr/bin/java
checking for javac... /usr/bin/javac
checking for javah... /usr/bin/javah
checking for jar... /usr/bin/jar
checking for javadoc... /usr/bin/javadoc
checking for Magick-config... /usr/local/bin/Magick-config
checking magick/api.h usability... no
checking magick/api.h presence... no
checking for magick/api.h... no
configure: error: 'Unable to find ImageMagick header files'

Já tentei baixar o Jar do JMagick (ou seja desistir de compilar), mas ai olha o erro:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no JMagick in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1028)
        at magick.MagickLoader.<clinit>(MagickLoader.java:13)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at magick.Magick.<clinit>(Magick.java:21)
        at univesp.metadados.exemplos.Readi.main(Readi.java:14)
Java Result: 1
package metadados.exemplos;

import magick.ImageInfo;
import magick.MagickException;
import magick.MagickImage;

public class Readi {
	public static void main(String[] a) throws MagickException{
		MagickImage image = new MagickImage(new ImageInfo("/home/paulopatto/Imagens/PATTO/bandeira_brasil.jpg"));
		System.out.println(image.getImageFormat());
	}
}

Tá pode reclamar que há não tem a lib do ImageMagick, bem eu fiz o seguinte:

paulopatto@paulopatto-workstation:/usr/lib$ sudo ln /home/paulopatto/Download/magick/jmagick-linux-6.4.0-Q32/libJMagick-6.4.0.so JMagick.so

paulopatto@paulopatto-workstation:/usr/lib$ sudo ln /home/paulopatto/Download/magick/jmagick-linux-6.4.0-Q32/libJMagick-6.4.0.so JMagick

Criar uma cópia da lib do ImageMagick no ext da JVM:

paulopatto@paulopatto-workstation:~/Desenvolvimento$ sudo cp /home/paulopatto/Download/magick/jmagick-linux-6.4.0-Q32/jmagick-6.4.0.jar /usr/lib/jvm/java-6-sun-1.6.0.20/ext

Modeifiquei o código java para isso:

package univesp.metadados.exemplos;

import magick.ImageInfo;
import magick.MagickException;
import magick.MagickImage;

public class Readi {
	public static void main(String[] a) throws MagickException{
		System.out.println(System.getProperty ("java.library.path"));
		System.setProperty("java.library.path", System.getProperty ("java.library.path")+":/usr/local/lib/");
		System.out.println(System.getProperty ("java.library.path"));
		MagickImage image = new MagickImage(new ImageInfo("/home/paulopatto/Imagens/PATTO/bandeira_brasil.jpg"));
		System.out.println(image.getImageFormat());
	}
}

E a saída:

/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib:/usr/local/lib/
Exception in thread "main" java.lang.UnsatisfiedLinkError: no JMagick in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1028)
        at magick.MagickLoader.<clinit>(MagickLoader.java:13)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at magick.Magick.<clinit>(Magick.java:21)
        at univesp.metadados.exemplos.Readi.main(Readi.java:14)
Java Result: 1

Sinceramente não estou vendo o por que deste erro. Já não sei mais o que fazer…

Ninguém mais???

Sinceramente estou quase desistindo de usar o JMagick!

Ok, problema resolvido. Não sou muito bom escritor mas postei a solução em meu blog. Visitem o link http://paulopatto.wordpress.com/2010/09/08/imagemagick-no-ubuntu/

Abraços e obrigado pela ajuda.