Bug: magickcore programs no longer link since IM 6.9.0

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
jcupitt
Posts: 26
Joined: 2011-04-26T05:14:01-07:00
Authentication code: 8675308

Bug: magickcore programs no longer link since IM 6.9.0

Post by jcupitt »

Hi, this is a repost, perhaps my subject line wasn't clear enough before.

The intro to magickcore page has a simple example program:

http://www.imagemagick.org/script/magick-core.php

It suggests you compile with

Code: Select all

cc -o core core.c `pkg-config --cflags --libs MagickCore`
But with recent (6.9 and later? I'm trying 6.9.2-4) imagemagick, this fails with a lot of link errors along the lines of:

Code: Select all

/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `PixelSetQuantumColor'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetClipRule'
.... etc.
It seems MagickCore and MagickWand now contain references to each other's functions. How should I compile MagickCore programs?

This is on Ubuntu 15.10.

User avatar
magick
Site Admin
Posts: 11215
Joined: 2003-05-31T11:32:55-07:00

Re: Bug: magickcore programs no longer link since IM 6.9.0

Post by magick »

Works for us, no linking errors. Did you set
  • export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

jcupitt
Posts: 26
Joined: 2011-04-26T05:14:01-07:00
Authentication code: 8675308

Re: Bug: magickcore programs no longer link since IM 6.9.0

Post by jcupitt »

Yes, I think I've set everything correctly.

Here's the IM configure summary:

Code: Select all

configure:
==============================================================================
ImageMagick is configured as follows. Please verify that this configuration
matches your expectations.

  Host system type: x86_64-unknown-linux-gnu
  Build system type: x86_64-unknown-linux-gnu

                 Option                        Value
  ------------------------------------------------------------------------------
  Shared libraries  --enable-shared=yes		yes
  Static libraries  --enable-static=yes		yes
  Module support    --with-modules=no		no
  GNU ld            --with-gnu-ld=yes		yes
  Quantum depth     --with-quantum-depth=16	16
  High Dynamic Range Imagery
                    --enable-hdri=no		no

  Install documentation:			yes

  Delegate Library Configuration:
  BZLIB             --with-bzlib=yes		yes
  Autotrace         --with-autotrace=no		no
  DJVU              --with-djvu=yes		yes
  DPS               --with-dps=yes		no
  FFTW              --with-fftw=yes		yes
  FlashPIX          --with-fpx=yes		no
  FontConfig        --with-fontconfig=yes	yes
  FreeType          --with-freetype=yes		yes
  Ghostscript lib   --with-gslib=no		no
  Graphviz          --with-gvc=yes		yes
  JBIG              --with-jbig=yes		yes
  JPEG v1           --with-jpeg=yes		yes
  LCMS              --with-lcms=yes		yes
  LQR               --with-lqr=yes		yes
  LTDL              --with-ltdl=yes		no
  LZMA              --with-lzma=yes		yes
  Magick++          --with-magick-plus-plus=yes	yes
  OpenEXR           --with-openexr=yes		yes
  OpenJP2           --with-openjp2=yes		no
  PANGO             --with-pango=yes		yes
  PERL              --with-perl=no		no
  PNG               --with-png=yes		yes
  RSVG              --with-rsvg=no		no
  TIFF              --with-tiff=yes		yes
  WEBP              --with-webp=yes		yes
  WMF               --with-wmf=yes		yes
  X11               --with-x=			yes
  XML               --with-xml=yes		yes
  ZLIB              --with-zlib=yes		yes

  Delegate Program Configuration:
  GhostPCL          None				pcl6 (unknown)
  GhostXPS          None				gxps (unknown)
  Ghostscript       None				gs (9.16)

  Font Configuration:
  Apple fonts       --with-apple-font-dir=default	none
  Dejavu fonts      --with-dejavu-font-dir=default	none
  Ghostscript fonts --with-gs-font-dir=default	/usr/share/fonts/type1/gsfonts/
  Windows fonts     --with-windows-font-dir=default	none

  X11 Configuration:
        X_CFLAGS        = 
        X_PRE_LIBS      =  -lSM -lICE
        X_LIBS          = 
        X_EXTRA_LIBS    = 

  Options used to compile and link:
    PREFIX          = /home/john/vips
    EXEC-PREFIX     = /home/john/vips
    VERSION         = 6.9.2
    CC              = gcc
    CFLAGS          = -I/usr/include/libxml2  -I/usr/include/libpng12   -pthread -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12  -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 -Wall -mtune=broadwell -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
    CPPFLAGS        =   -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 
    PCFLAGS         = 
    DEFS            = -DHAVE_CONFIG_H
    LDFLAGS         =  
    LIBS            = 
    CXX             = g++
    CXXFLAGS        = -g -pthread
    FEATURES        = DPC Cipher OpenMP
    DELEGATES       = bzlib djvu mpeg fftw fontconfig freetype jbig jng jpeg lcms lqr lzma openexr pango png ps tiff webp wmf x xml zlib
==============================================================================
I see this for pkg-config:

Code: Select all

$ pkg-config --cflags --libs MagickCore
-fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/home/john/vips/include/ImageMagick-6 -L/home/john/vips/lib -lMagickCore-6.Q16 
But when I try to compile I see this:

Code: Select all

$ cc -o core core.c `pkg-config --cflags --libs MagickCore`
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DestroyPixelWand'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `PixelSetColor'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetStrokeWidth'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawRectangle'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPushPattern'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetStrokeColor'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPathLineToAbsolute'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawRoundRectangle'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawAnnotation'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPathStart'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetClipPath'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPathClose'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetViewbox'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `PixelSetRedQuantum'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPopClipPath'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetStrokeAntialias'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DestroyMagickWand'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DestroyDrawingWand'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawColor'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `NewMagickWandFromImage'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawScale'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawLine'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `PixelSetOpacityQuantum'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawRender'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetStrokePatternURL'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetFillPatternURL'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPushDefs'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawAllocateWand'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawComment'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `PixelSetBlueQuantum'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetFontSize'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetStrokeDashArray'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPathMoveToAbsolute'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPushClipPath'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPopPattern'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPathFinish'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetTextUnderColor'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetFillColor'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetFont'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `NewPixelWand'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawArc'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawRotate'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `PopDrawingWand'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `PixelSetGreenQuantum'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawTranslate'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetClipRule'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawComposite'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPathEllipticArcAbsolute'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetStrokeLineJoin'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawPopDefs'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `PushDrawingWand'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawSetStrokeLineCap'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `PixelSetQuantumColor'
/home/john/vips/lib/libMagickCore-6.Q16.so: undefined reference to `DrawEllipse'
collect2: error: ld returned 1 exit status

jcupitt
Posts: 26
Joined: 2011-04-26T05:14:01-07:00
Authentication code: 8675308

Re: Bug: magickcore programs no longer link since IM 6.9.0

Post by jcupitt »

This is with an Ubuntu-installed ImageMagick on the system as well, I don't know if that could be a factor. The system one links fine, it's the 6.9.2 I'm trying to build for testing that's not linking.

I can't easily remove the system one without breaking a lot of stuff, but I did try hiding the ImageMagick.pc and MagickCore.pc files in /usr/lib/x86_64-linux-gnu/pkgconfig and rebuilding 6.9.2. It didn't seem to make any difference.

jcupitt
Posts: 26
Joined: 2011-04-26T05:14:01-07:00
Authentication code: 8675308

Re: Bug: magickcore programs no longer link since IM 6.9.0

Post by jcupitt »

I did a little digging, the problem seems to be that the coders are being linked into libMagickCore.

When libMagickCore-6.Q16.so is linked, the coders are included, and wmf.c uses functions like DrawPathFinish(), which are part of Wand, not Core.

Therefore MagickCore programs will not link with default configure settings, you must use --with-modules.

Should --with-modules be made the default if shared libraries are enabled? It doesn't seem right that MagickCore linking should fail with the default settings.

Alternatively, perhaps wmf.c could be linked into Wand rather than Core, since it depends on Wand functions.

User avatar
magick
Site Admin
Posts: 11215
Joined: 2003-05-31T11:32:55-07:00

Re: Bug: magickcore programs no longer link since IM 6.9.0

Post by magick »

We'll update the documentation to reflect the WMF dependency. In the mean-time, use this build command:
  • cc -o core core.c `pkg-config --cflags --libs MagickWand`

Post Reply