[英]Assertion failed. trying to create an image using Magick++
I am trying to run this simple code from thisexample on page 8. I am trying to create an image and then write it but it won't even let me create the image.我正在尝试从第 8 页上的示例中运行这个简单的代码。我正在尝试创建一个图像然后编写它,但它甚至不会让我创建图像。
This is the code:这是代码:
#include <Magick++.h>
#include <iostream>
int main()
{
Magick::Image p("300x300", "red");
//~ p.write("red.png");
return 0;
}
Here is the compilation command:下面是编译命令:
g++ Magick++-config --cppflags --cxxflags --ldflags --libs main.cpp -o main
Here is the error:这是错误:
main: magick/semaphore.c:606: LockSemaphoreInfo: Assertion `semaphore_info != (SemaphoreInfo *) NULL' failed.
Aborted
I am using Debian 9 on Virtualbox.我在 Virtualbox 上使用 Debian 9。 It compiles perfectly fine.它编译得很好。 It just doesn't run and I don't know what that error means.它只是不运行,我不知道该错误意味着什么。 I also can't find it online.我在网上也找不到。 Can someone please help?有人可以帮忙吗?
I hadn't initialized magick because I thought that was only for windows users.我没有初始化魔法,因为我认为这仅适用于 Windows 用户。 Here is the updated code.这是更新的代码。
#include <Magick++.h>
#include <iostream>
int main()
{
Magick::InitializeMagick(nullptr); // <--- added this line
Magick::Image p("300x300", "red");
p.write("red.png");
return 0;
}
I hope this helps anyone else facing this issue.我希望这可以帮助其他人面临这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.