Page 1 of 1

Having trouble finding -lmagick++

Posted: 2017-06-12T17:37:59-07:00
by PartPangolin
Hello!

I'm currently trying to get a simple c++ code to compile with the Magick++ API. The actual code I'm comipling is dirt simple. Just a "hello world" with #include Magick++.h at the top.

The problem is that the compiler cant seem to find -lMagick++. See the error below

ImageMagick was installed from binaries in cygwin over windows 7. I did the following configuration after install

Code: Select all

export MAGICK_HOME="$HOME/ImageMagick-6.8.8"
export PATH="$MAGICK_HOME/bin:$PATH"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MAGICK_HOME/lib"
export PKG_CONFIG_PATH="$MAGICK_HOME/lib/pkgconfig"
When I type

Code: Select all

identify -list configure
The following is returned

Code: Select all

Path: /usr/lib/ImageMagick-6.7.6/config/configure.xml

Name          Value
-------------------------------------------------------------------------------
CC            gcc -std=gnu99 -std=gnu99
CFLAGS        -fopenmp -g -O2 -pipe -Wall
CODER_PATH    /usr/lib/ImageMagick-6.7.6/modules-Q16/coders
CONFIGURE     /pub/devel/imagemagick/ImageMagick-6.7.6.3-1/src/ImageMagick-6.7.6                                -3/configure  '--srcdir=/pub/devel/imagemagick/ImageMagick-6.7.6.3-1/src/ImageMa                                gick-6.7.6-3' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindi                                r=/usr/sbin' '--libexecdir=/usr/lib' '--datadir=/usr/share' '--localstatedir=/va                                r' '--sysconfdir=/etc' '--datarootdir=/usr/share' '--docdir=/usr/share/doc/Image                                Magick' '-C' '--disable-static' '--without-modules' '--with-quantum-depth=16' '-                                -with-autotrace' '--with-bzlib' '--with-dps' '--with-fftw' '--with-fontconfig' '                                --with-fpx' '--with-freetype' '--with-gslib' '--with-gvc' '--with-jbig' '--with-                                jpeg' '--with-jp2' '--without-lcms' '--with-lcms2' '--with-lzma' '--with-pango'                                 '--with-png' '--with-rsvg' '--with-tiff' '--without-wmf' '--with-x' '--with-xml'                                 '--with-zlib' '--without-included-ltdl' '--with-ltdl-include=/usr/include' '--w                                ith-ltdl-lib=/usr/lib' '--with-fontpath=/usr/share/fonts' '--with-gs-font-dir=/u                                sr/share/ghostscript/fonts' '--with-windows-font-dir=/usr/share/fonts/TTF' '--wi                                th-perl' '--with-perl-options=INSTALLDIRS=vendor' 'CC=gcc' 'CFLAGS=-g -O2 -pipe                                 ' 'LDFLAGS=' 'LIBS=' 'CPPFLAGS=' 'CXX=g++' 'CXXFLAGS=-g -O2 -pipe '
CONFIGURE_PATH /etc/ImageMagick/
COPYRIGHT     Copyright (C) 1999-2012 ImageMagick Studio LLC
CPPFLAGS      -I/usr/include/ImageMagick
CXX           g++
CXXFLAGS      -g -O2 -pipe
DEFS          -DHAVE_CONFIG_H
DELEGATES     autotrace bzlib fftw fpx fontconfig freetype gs jbig jpeg jng jp2                                 lcms2 lzma png rsvg tiff x11 xml zlib
DISTCHECK_CONFIG_FLAGS 'CC=gcc' 'CFLAGS=-g -O2 -pipe ' 'CPPFLAGS=' 'CXX=g++' 'LD                                FLAGS=' 'LIBS=' --disable-deprecated --with-quantum-depth=16 --with-umem=no --wi                                th-fontpath=/usr/share/fonts --with-gs-font-dir=/usr/share/ghostscript/fonts --w                                ith-lcms=no --with-windows-font-dir=/usr/share/fonts/TTF --with-wmf=no
DOCUMENTATION_PATH /usr/share/doc/ImageMagick/
EXEC-PREFIX   /usr
EXECUTABLE_PATH /usr/bin
FEATURES      OpenMP 
FILTER_PATH   /usr/lib/ImageMagick-6.7.6/modules-Q16/filters
HOST          i686-pc-cygwin
INCLUDE_PATH  /usr/include/ImageMagick
LDFLAGS       -L/usr/lib -L/usr/lib
LIB_VERSION   0x676
LIB_VERSION_NUMBER 6,7,6,3
LIBRARY_PATH  /usr/lib/ImageMagick-6.7.6
LIBS          -lMagickCore -ljbig -llcms2 -ltiff -lfreetype -ljasper -ljpeg -lgs                                 -lpng14 -Wl,--enable-auto-import -fopenmp -lautotrace -lfreetype -lMagickWand -                                lMagickCore -lming -lm -lpstoedit -lpng -lz -lstdc++ -ldl -lfftw3 -lfpx -lfontco                                nfig -lexpat -lfreetype -lz -lbz2 -liconv -lXext -lXt -lSM -lICE -lX11 -llzma -l                                bz2 -lpangocairo-1.0 -lcairo -lpangoft2-1.0 -lpixman-1 -lpng14 -lxcb-shm -lxcb-r                                ender -lXrender -lX11 -lxcb -lXau -lXdmcp -lpango-1.0 -lm -lfontconfig -lexpat -                                lfreetype -lz -lbz2 -lgobject-2.0 -lffi -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -                                lintl -liconv -L/usr/bin -lrsvg-2 -lgio-2.0 -lgdk_pixbuf-2.0 -lm -lcairo -lgmodu                                le-2.0 -lgobject-2.0 -lffi -lpixman-1 -lfontconfig -lexpat -lfreetype -lbz2 -lpn                                g14 -lz -lxcb-shm -lxcb-render -lXrender -lgthread-2.0 -lglib-2.0 -lintl -liconv                                 -lX11 -lxcb -lXau -lXdmcp -lxml2 -lz -lgdi32 -lm -lgomp -lpthread -lltdl
NAME          ImageMagick
PCFLAGS       -fopenmp
PREFIX        /usr
QuantumDepth  16
RELEASE_DATE  2012-04-01
SHARE_PATH    /usr/share/ImageMagick-6.7.6
SVN_REVISION  7291
TARGET_CPU    i686
TARGET_OS     cygwin
TARGET_VENDOR pc
VERSION       6.7.6
WEBSITE       http://www.imagemagick.org

Path: [built-in]

Name          Value
-------------------------------------------------------------------------------
NAME          ImageMagick
The CPP file is as follows:

Code: Select all

#include <iostream>
#include <Magick++.h>
using namespace std;

int main( int argc, char ** argv) 
{
    InitializeMagick(*argv);
    cout<<"Hello Magick++"<<endl;
    return 0;
}
This was compiled using:

Code: Select all

g++ `Magick++-config --cppflags` -o hello hello_world.cpp \ `Magick++-config --ldflags --libs`
And the compiler spits back:

Code: Select all

g++:  -lMagick++: No such file or directory 
cc1plus: warning: command line option "-fopenmp" is valid for D but not for C++
hello_world.cpp: In function `int main(int, char**)':
hello_world.cpp:7: error: `InitializeMagick' undeclared (first use this function)
hello_world.cpp:7: error: (Each undeclared identifier is reported only once for each function it appears in.)
What am I doing wrong?? I've been trying to figure this out for hours... :/

THANK YOU!!

Re: Having trouble finding -lmagick++

Posted: 2017-06-12T20:10:31-07:00
by snibgo
I think your problem is that your g++ command uses "Magick++-config", but you export "PKG_CONFIG_PATH". I think you need either Magick++ for both, or PKG for both.


This is how I build Magick++ programs under Cygwin (bash script):

Code: Select all

export PKG_CONFIG_PATH=${IMDEV}../lib/pkgconfig

while [ $# -gt 0 ]
  do

  c++ -o "$1".exe "$1".cpp -Wall -Wa,-march=corei7,-mtune=corei7 `pkg-config --cflags --libs Magick++`

  cp "$1".exe ${IMDEV}

  shift   # next option
done
The loop is simply so I can build multiple programs at once.

${IMDEV} is the directory for my build, of course. This works for v6 or v7. It's an old script, and I think the current "official" method uses something else instead of PKG_CONFIG_PATH. Quite possibly it is MAGICK++_CONFIG_PATH.