Re: Help using GM with CMake

Bob Friesenhahn <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Sun, 22 Jul 2018, Scott Harvey wrote:
>
> I can't use the traditional method of asking CMake to "find_package" for 
> GraphicsMagick - doesn't appear to provide one. If I forcibly add the 
> directory (/usr/include/GraphicsMagick), my project will finally find 
> "Magick++.h".

GraphicsMagick is not built using CMake, so perhaps that makes a 
difference for finding a package.

> CMakeFiles/gaussian.dir/gaussian.cpp.o: In function `main':
> gaussian.cpp:(.text+0x27): undefined reference to 
> `Magick::InitializeMagick(char const*)'
> gaussian.cpp:(.text+0x5b): undefined reference to 
> `Magick::Image::Image(std::__cxx11::basic_string<char, 
> std::char_traits<char>, std::allocator<char> > const&)'
> gaussian.cpp:(.text+0xa7): undefined reference to 
> `Magick::Image::read(std::__cxx11::basic_string<char, std::char_traits<char>, 
> std::allocator<char> > const&)'
> gaussian.cpp:(.text+0xcb): undefined reference to `Magick::Image::~Image()'
> gaussian.cpp:(.text+0x129): undefined reference to `Magick::Image::~Image()'
>
> ---
>
> Can someone help me? Between IM and GM, I've been at this for almost 24 
> hours. My system is openSUSE Tumbleweed and is in otherwise working 
> condition. If it matters, I've installed GM from the openSUSE package manager 
> rather than install from source.

Dependending on how Suse packages work, you may or may not need to 
install development versions of the packages in order to do software 
development with them.

Hopefully your almost 24 hours has included reading the Magick++ 
documentation at "http://www.graphicsmagick.org/Magick++/index.html". 
At the bottom of the page there is an example of how to compile a 
sample program using the installed 'GraphicsMagick++-config' script, 
which remembers build settings:

c++ -o example example.cpp `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs`

If you run just

   GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs

you should see a bunch of suggested build options printed on the 
screen.

There are other ways to get build settings, such as from pkg-config.

You are at the cusp of success.  Get your example building manually 
before worrying about CMake and your larger project.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.