0

I installed all the libmagick-dev packages (magickwand, magick++, etc) in Ubuntu 16.04 but I don't know where is the library... So I haven't included it to my C program.
I need to use the pixel level functions for a project I'm developing
When typing 'locate libmagick', I just get the /usr/share/doc stuff. It's the docs, not the libraries.
I need to include the .h files to my program so I can manipulate images.
At the moment, I'm making tests for the image manipulations (simple programs that are in the imagemagick.org site wich use the magickwand API)...
But that's a thing I don't know how to do...
Where's the library?
That's a first step :(

Installed -dev Packages:
libmagick++-6.q16-dev (imagemagick C++ developer API)
libmagickcore-6.q16-dev (magickcore low-access API for C)
libmagickcore-6-headers
libmagickwand-6.q16-dev (magickwand C developer API)
libmagickwand-6-headers
I also installed the libmagickwand-dev package, though apt says it's a transitional package that could be removed...
I've read that those packages would be enough, but it seems it's not... Thanks for your replies ;-)

  • Did you run `./configure; make; sudo make install`? – Mark Setchell Oct 17 '16 at 08:24
  • EDIT: I installed Debian yesterday... Didn't like Ubuntu at all :-/ Then, installed it on Debian. As far as I know, Debian doesn't need to compile. It installs precompiled packages using dpkg, and those ones are in the repositories (the Debian's packages collection) :( Am I wrong? It needs another config? – Sergio Pastor Oct 17 '16 at 21:10

2 Answers2

1

On a Ubuntu/Debian system, the libraries are usually under /usr/lib, or a subdirectory managed by the package installer + system architecture.

You can find them with...

find /usr/lib -name 'libMagick*'

The actual location is not terribly important as you should be leveraging pkg-config, or MagickWand-config utility for the required CC + LD flags.

For example

pkg-config --cflags --libs MagickWand
#=> -fopenmp -I/usr/include/ImageMagick  -lMagickWand -lMagickCore

or

MagickWand-config --cflags --libs
#=> -fopenmp -I/usr/include/ImageMagick
#   -lMagickWand -lMagickCore

So a simple MagickWand test can be something like...

// test.c (creates a single rose.bmp image for testing)
#include <wand/MagickWand.h>

int main()
{
    MagickWandGenesis();
    MagickWand *test = NewMagickWand();
    MagickReadImage(test, "rose:");
    MagickWriteImage(test, "rose.bmp");
    DestroyMagickWand(test);
    MagickWandTerminus();
    return 0;
}

And can be compiled with..

cc -o make_rose_image $(pkg-config --cflags --libs MagickWand) test.c
emcconville
  • 23,800
  • 4
  • 50
  • 66
  • I answered a wrong thing ¬¬ I mean, thanks, but it still doesn't work.... :(
    When typed `pkg-config --cflags --libs MagickWand`, got `-fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6 -lMagickWand-6.Q16 -lMagickCore-6.Q16`
    – Sergio Pastor Oct 19 '16 at 21:02
  • Excuse me for that awful code. I do not see the "edit" button...
    When typed `cc -o rose $(pkg-config --cflags --libs MagickWand)$ pruebaimg.c`, got `unrecognized command line option [that thing]` :-/
    – Sergio Pastor Oct 19 '16 at 21:08
  • My mother language is spanish... That "pruebaimg.c" is your "test.c" – Sergio Pastor Oct 19 '16 at 21:16
  • You have an invalid command line option `$` after invoking pkg-config. But your on the right track. You've located the libraries, and have identified the correct flags to pass to your compiler. Try `gcc -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu/ImageMagick-6 -I/usr/include/ImageMagick-6 -lMagickWand-6.Q16 -lMagickCore-6.Q16 -o rose pruebaimg.c` – emcconville Oct 19 '16 at 21:20
  • IT WORKS!! Thank you! – Sergio Pastor Oct 19 '16 at 22:02
  • Now I have to make my pixel image :) Could I ask you to look at my code? I'm trying to draw a fractal ;-) Just the lib's call lines. :D – Sergio Pastor Oct 19 '16 at 22:04
  • Happy to help. If you found my answer helpful, please +1 it. If your original questions was answered, please accept the answer so future readers will know. If you have additional questions, please open a new question. – emcconville Oct 19 '16 at 22:17
  • OK :) Thank you. I wrote something else to explain what you said to me :) – Sergio Pastor Oct 19 '16 at 22:20
0

What I had to do was installing the libmagick-dev libraries. They were at /usr/lib.
When typing find /usr/lib -name 'libMagick*', got

/usr/lib/x86_64-linux-gnu/libMagick++-6.Q16.a
/usr/lib/x86_64-linux-gnu/libMagick++-6.Q16.so
/usr/lib/x86_64-linux-gnu/libMagickCore-6.Q16.so.2.0.0
/usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so
/usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.a
/usr/lib/x86_64-linux-gnu/libMagick++-6.Q16.la
/usr/lib/x86_64-linux-gnu/libMagick++-6.Q16.so.5.0.0
/usr/lib/x86_64-linux-gnu/libMagickCore-6.Q16.so
/usr/lib/x86_64-linux-gnu/libMagick++-6.Q16.so.5
/usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so.2
/usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so.2.0.0
/usr/lib/x86_64-linux-gnu/libMagickCore-6.Q16.so.2
/usr/lib/x86_64-linux-gnu/libMagickCore-6.Q16.a
/usr/lib/x86_64-linux-gnu/libMagickCore-6.Q16.la
/usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.la

And there they are!
The libraries are in /usr/lib
And a program who uses MagickWand is called by
cc -o output $(pkg-config --cflags --libs MagickWand) source.c

:)