gpt4 book ai didi

C++ Boost 和 ImageMagick++ API 问题

转载 作者:行者123 更新时间:2023-11-27 23:54:29 29 4
gpt4 key购买 nike

在开发由 g++4.9.2 编译的 Raspberry Pi 库时,我遇到了 boost (1.6.2) 和 ImageMagick++ API (7.0) 之间的兼容性问题。编译这段代码时:

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

我遇到了这些 boost 错误:

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

删除时#include <Magick++.h>线路一切正常。不幸的是,我在这个源文件中也需要 boost 和 ImageMagick。如何解决这个问题?

最佳答案

一个简单的解决方法是在 boost 之后包含 Magick++.h。

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

我对这个问题没有正确的解释,但它似乎来自于使用包括 assert.h 在内的不同 header 时的冲突(我在使用 assimp 库和 ImageMagick 时遇到了同样的问题)但我不明白为什么顺序很重要。

重现您的案例,assert.h 包含在:

  • boost 卡塞特
  • MagickCore/pixel-accessor.h for Magick++.h

如果有人对此问题有解释,请随时编辑。

关于C++ Boost 和 ImageMagick++ API 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43678937/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com