r/C_Programming • u/Jakanader • Oct 25 '26
Meson linking ImageMagick/Wand
I'm trying to link MagickWand and MagickCore with Meson and having some issues. Specifically, I get the error C shared or static library 'lMagickCore' not found or C shared or static library 'lMagickWand' not found. I successfully linked libconfig, so I've compared some details between my installations of the two packages in case any of those are the reason that I'm having issues with ImageMagick.
I can compile programs using ImageMagick libraries with:
```cc MagickWand-config --cflags --cppflags -O2 -o a.out main.c MagickWand-config --ldflags --libs
The output of the two MagickWand-config calls is this:
```-I/usr/include/ImageMagick-7 -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_CHANNEL_MASK_DEPTH=32
-lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI
-lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI
Running find /usr/lib -name 'libconfig*' gives this:
/usr/lib/pkgconfig/libconfig.pc
/usr/lib/cmake/libconfig
/usr/lib/cmake/libconfig/libconfigConfig.cmake
/usr/lib/cmake/libconfig++
/usr/lib/cmake/libconfig++/libconfig++Config.cmake
/usr/lib/libreoffice/program/libconfigmgrlo.so
/usr/lib/libconfig++.so
/usr/lib/libconfig++.so.15
/usr/lib/libconfig++.so.15.0.0
/usr/lib/libconfig.so
/usr/lib/libconfig.so.15
/usr/lib/libconfig.so.15.0.0
And running find /usr/lib -name 'libMagick*' gives this:
/usr/lib/libMagick++-7.Q16HDRI.so.5
/usr/lib/libMagick++-7.Q16HDRI.so.5.0.0
/usr/lib/libMagickCore-7.Q16HDRI.so
/usr/lib/libMagickCore-7.Q16HDRI.so.10
/usr/lib/libMagickCore-7.Q16HDRI.so.10.0.3
/usr/lib/libMagickWand-7.Q16HDRI.so
/usr/lib/libMagickWand-7.Q16HDRI.so.10
/usr/lib/libMagickWand-7.Q16HDRI.so.10.0.3
My meson.build has these relevant sections:
cc.find_library('libtomlc17', dirs: '/usr/local/lib'),
dependency('libconfig'),
dependency('libMagickCore'),
dependency('libMagickWand'),
]
inc_dir = [
include_directories('include'),
include_directories('/usr/include/ImageMagick-7'),
]
my first guess was that it had something to do with libconfig having .pc files in /usr/lib/pkgconfig, but i found ImageMagick.pc and ImageMagick-7.Q16HDRI.pc in the same directory, and, either way, that don't seem like it needs to be accurate for my program to build as long as I give it all the right information.
Any advice?
Edit: Also, reddit's code block formatting is really annoying. It doesn't seem like I can escape backticks? and it doesn't render line breaks? oh well
4
u/aioeu Oct 25 '26 edited Oct 25 '26
Use 4-space indents.
That is:
will produce:
I use this website sometimes to preview things before posting. (Maybe New Reddit can do that automatically, but I don't use that.)
1
u/catbrane Oct 25 '26
Don't use the old
MagickWand-configscript, stick topkg-config. I use this:And it seems to work fine.
You'll find a few environments are missing the
MagickCore.pcfiles, annoyingly.