cant compile C program from example. IM 7.0.2 . Ubuntu. Fatal error.

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
josephaaroncampbell
Posts: 40
Joined: 2015-07-14T19:18:45-07:00
Authentication code: 1151
Location: Chicago, IL

cant compile C program from example. IM 7.0.2 . Ubuntu. Fatal error.

Post by josephaaroncampbell » 2016-07-02T20:58:33-07:00

Hello,

I just installed IM from source folowing these instructions:
http://www.imagemagick.org/script/install-source.php

Code: Select all

identify -version


returns:
Version: ImageMagick 7.0.2-2 Q16 x86_64 2016-07-02 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): bzlib djvu fontconfig freetype gvc jbig jng jpeg lcms lqr lzma openexr png tiff wmf x xml zlib
Everything seems to have gone ok. But when I follow the tutorial for MagickWand here:
http://www.imagemagick.org/script/magick-wand.php

Code: Select all

cc -o wand wand.c `pkg-config --cflags --libs MagickWand`
returns the following error:
wand.c:3:29: fatal error: wand/MagickWand.h: No such file or directory
#include <wand/MagickWand.h>
^
compilation terminated.
My first thought was to update the $PATH variable but I am not having too much luck with that working. I have found it to be similar to this post:
https://www.imagemagick.org/discourse-s ... nd#p127177

So here is my configure info.

Code: Select all

identify -list configure
Path: /usr/local/lib/ImageMagick-7.0.2//config-Q16HDRI/configure.xml

Name Value
-------------------------------------------------------------------------------
CC gcc -std=gnu99 -std=gnu99
CFLAGS -I/usr/include/libxml2 -I/usr/include/libpng12 -pthread -I/usr/include/OpenEXR -I/usr/include/lqr-1 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/graphviz -I/usr/include/freetype2 -I/usr/include/freetype2 -pthread -fopenmp -g -O2 -Wall -mtune=corei7 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
CODER_PATH /usr/local/lib/ImageMagick-7.0.2/modules-Q16HDRI/coders
CONFIGURE ./configure 'PKG_CONFIG_PATH=/usr/local/lib/pkgconfig'
CONFIGURE_PATH /usr/local/etc/ImageMagick-7/
COPYRIGHT Copyright (C) 1999-2016 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/include/ImageMagick-7
CXX g++
CXXFLAGS -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES bzlib djvu mpeg fontconfig freetype jbig jng jpeg lcms lqr lzma openexr png ps tiff wmf x xml zlib
DISTCHECK_CONFIG_FLAGS --disable-deprecated --with-quantum-depth=16 --with-jemalloc=no --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-rsvg=no --with-perl=no
DOCUMENTATION_PATH /usr/local/share/doc/ImageMagick-7
EXEC-PREFIX /usr/local
EXECUTABLE_PATH /usr/local/bin
FEATURES DPC HDRI Cipher OpenMP
FILTER_PATH /usr/local/lib/ImageMagick-7.0.2/modules-Q16HDRI/filters
GIT_REVISION 11033
HOST x86_64-unknown-linux-gnu
INCLUDE_PATH /usr/local/include/ImageMagick-7
LDFLAGS -L/usr/local/lib
LIB_VERSION 0x702
LIB_VERSION_NUMBER 7,0,2,2
LIBRARY_PATH /usr/local/lib/ImageMagick-7.0.2
LIBS -ljbig -llcms2 -ltiff -lfreetype -ljpeg -llqr-1 -lglib-2.0 -lpng12 -ldjvulibre -lfontconfig -lfreetype -lwmflite -lXext -lXt -lSM -lICE -lX11 -llzma -lbz2 -pthread -lIlmImf -lz -lImath -lHalf -lIex -lIlmThread -lxml2 -lgvc -lcgraph -lcdt -lz -lm -lgomp
NAME ImageMagick
PCFLAGS -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
PREFIX /usr/local
QuantumDepth 16
RELEASE_DATE 2016-07-02
SHARE_PATH /usr/local/share/ImageMagick-7
SHAREARCH_PATH /usr/local/lib/ImageMagick-7.0.2/config-Q16HDRI
TARGET_CPU x86_64
TARGET_OS linux-gnu
TARGET_VENDOR unknown
VERSION 7.0.2
WEBSITE http://www.imagemagick.org

Path: [built-in]

Name Value
-------------------------------------------------------------------------------
FEATURES OpenMP
NAME ImageMagick
QuantumDepth 16
I dont know if it matters. But i am running a guest Ubuntu 14.04 64bit in VirtualBox v5.0.22 r108108 on host Windows 10 64bit.

I read through the advanced Unix installation info and maybe I need to do something different? I am just at the beginnings of learning C and how to compile programs. So thank you for your time and your patience.

snibgo
Posts: 12298
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: cant compile C program from example. IM 7.0.2 . Ubuntu. Fatal error.

Post by snibgo » 2016-07-02T22:55:27-07:00

See the V7 porting guide http://www.imagemagick.org/script/porting.php, especially the note about header file directories: MagickWand instead of wand, etc. Also possibly "MagickWand-config" instead of "pkg-config".
snibgo's IM pages: im.snibgo.com

josephaaroncampbell
Posts: 40
Joined: 2015-07-14T19:18:45-07:00
Authentication code: 1151
Location: Chicago, IL

Re: cant compile C program from example. IM 7.0.2 . Ubuntu. Fatal error.

Post by josephaaroncampbell » 2016-07-03T08:31:49-07:00

thank you! I will check that out.

josephaaroncampbell
Posts: 40
Joined: 2015-07-14T19:18:45-07:00
Authentication code: 1151
Location: Chicago, IL

Re: cant compile C program from example. IM 7.0.2 . Ubuntu. Fatal error.

Post by josephaaroncampbell » 2016-07-04T11:07:12-07:00

So the porting guide helped solve the issues. Updating the example code to the v7 header names, function calls, and locations did the trick.

example of updated C program "wandTest.c" :

Code: Select all

#include "MagickWand/MagickWand.h"

int main(int argc, char *argv[])

{
    MagickWand *newWand;

    MagickWandGenesis();

    newWand = NewMagickWand();

    MagickReadImage(newWand, "test.tif" );

    MagickWriteImage(newWand, "test.jpg" );

    if(newWand) DestroyMagickWand(newWand);

    void MagickWandTerminus(void);

    return 0;
}
this compiled and executed with out any errors using:
cc -o wandTest wandTest.c `pkg-config --cflags --libs MagickWand`


Im running Ubuntu 14.04 x64 with IM version 7.0.2-2


Thank You Again for your help.

Post Reply