Marcin Zdunek
Marcin Zdunek

Reputation: 81

C++ Boost and ImageMagick++ API issue

While developing Raspberry Pi library compiled by g++4.9.2 I have met compability issue between boost (1.6.2) and ImageMagick++ API (7.0). When compiling this code:

#include <Magick++.h>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>

I got these boost errors:

__assert_fail was not declared in this scope (path_trails.hpp)
...
__assert_fail was not declared in this scope (path.hpp)
...
__assert_fail was not declared in this scope (shared_ptr.hpp)

When deleting #include <Magick++.h> line everything runs fine. Unfortunately I need boost and ImageMagick as well in this source file. How to solve this issue?

Upvotes: 2

Views: 364

Answers (1)

Leonarsy42
Leonarsy42

Reputation: 41

A simple workaround is to include Magick++.h after boost.

#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <Magick++.h>

I don't have a proper explanation for this problem but it seems to come from a clash when using different headers including assert.h (I had the same problem using the assimp library and ImageMagick) but I don't get why the order matters.

Reproducing your case, assert.h is included in:

  • cassert for boost
  • MagickCore/pixel-accessor.h for Magick++.h

If someone has an explanation for this problem feel free to edit.

Upvotes: 4

Related Questions