Sergio Pastor Sergio Pastor - 1 month ago 4
C Question

where's libmagickwand-dev (I installed them all) and how can I include it to a C program

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 ;-)

Answer

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
Comments