Saturday, February 19, 2022

[SOLVED] Build x86 ImageMagick application on x86_64 linux system

Issue

I have x86 C++ application which using ImageMagic++ library. I also have machine with CentOS 7 x86_64. I need to build my application on this machine. I have installed i686 ImageMagick library:

[dvoryankin@testsuitel]$ yum list installed | grep Magick
 ImageMagick.i686                   6.7.8.9-10.el7                      @base    
 ImageMagick-c++.i686               6.7.8.9-10.el7                      @base    
 ImageMagick-c++-devel.i686         6.7.8.9-10.el7                      @base    
 ImageMagick-devel.i686             6.7.8.9-10.el7                      @base

When I try to build my application I have an error:

/usr/include/ImageMagick/magick/magick-config.h:9:31:
fatal error: magick-config-64.h: No such file or directory
    #include "magick-config-64.h"

It's happened becuase file /usr/include/ImageMagick/magick/magick-config.h use macro definition __WORDSIZE to determine which file must be included magick-config-64.h or magick-config-32.h. On my machine with CentOS 7 x86_64 this macro is equal 64 and ImageMagick try to include magick-config-64.h but i686 library doesn't have this, only magick-config-32.h.

How I can build x86 application with x86 ImageMagick library on CentOS 7 x86_64 machine without change any library files?


Solution

I can only suggest rebuilding ImageMagick & delegates in an isolated location (not /usr/ directory).

curl -O http://www.imagemagick.org/download/ImageMagick.tar.gz
tar zvxf ImageMagick.tar.gz && cd ImageMagick-6.9.2-4
CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 \
./configure --build=i686-pc-linux-gnu --prefix=/opt/im32

Provided you have everything you need for to build cross-platform, and you already have all ImageMagick dependencies built in x86.

The utility /opt/im32/bin/Magick++-config can be used to print out the additional compiler/linker flags need for your application.



Answered By - emcconville
Answer Checked By - Mary Flores (WPSolving Volunteer)